从特定文件夹Android中选择图像

时间:2017-07-06 09:30:22

标签: android uri

您好我想从特定文件夹中获取图片。现在我使用这段代码:

                    Intent intent = new Intent();
                    Uri uri = Uri.parse(Environment.DIRECTORY_PICTURES);
                    intent.setDataAndType(uri, "image/*");
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    startActivityForResult(Intent.createChooser(intent,"Scegli foto"),PICK_IMAGE_REQUEST);

现在,随着那个uri我看到最近,我必须手动打开文件夹。我尝试用我的文件夹的路径设置uri.parse输入,但我还是得到了我的最近。我怎么能自动打开我的文件夹?

1 个答案:

答案 0 :(得分:0)

试试这个我的朋友

SELECT Data, Groupkey FROM (SELECT Data, GroupKey FROM MyTable GROUP BY Groupkey) WHERE Data2 <> 'Stuff'

像这样设置图片

    private void getImages() {
    String[] filenames = new String[0];
    File path = new File(Environment.getExternalStorageDirectory() + "/FolderName");
    if (path.exists()) {
        filenames = path.list();
    }
    ArrayList<String> imagesPathArrayList;

    for (int i = 0; i < filenames.length; i++) {
        imagesPathArrayList.add(path.getPath() + "/" + filenames[i]);
        Log.e("FAV_Images", imagesPathArrayList.get(i));
        ///Now set this bitmap on imageview
    }
}