3
我正在使用列出所有图像的代码,并且我试图弄清楚如何仅从特定文件夹获取图像,而不是所有图像。下面是我使用的代码:Android从SD卡获取图像
ArrayList<Bitmap> images = new ArrayList<Bitmap>();
String[] projection = {MediaStore.Images.Thumbnails.DATA};
Uri uri = Uri.parse("content://media/external/images/media");
cursor = managedQuery(uri, projection, null, null, null);
//cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
Log.i("MediaStore.Images.Media.EXTERNAL_CONTENT_URI", "MediaStore.Images.Media.EXTERNAL_CONTENT_URI: " + MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
if(cursor.getCount()==0){
Log.i("No Cards","No Cards");
cursor.close();
} else if(cursor.getCount()>0){
for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()){
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
String imagePath = cursor.getString(columnIndex);
Log.i("imagePath", "imagePath: " + imagePath);
Bitmap b = BitmapFactory.decodeFile("/Stampii" + imagePath, null);
images.add(b);
}
}
,我想要做的事情是从imagePath: /mnt/sdcard/Stampii/MediaCategory-251.jpg
Stampii文件夹获取的图像,但我不知道如何进入正确的道路到该文件夹。我已经尝试过:
Uri uri = Uri.parse("content://media/external/images/media/mnt/sdcard/Stampii");
任何解决方案?