2
我使用下面的代碼獲取所有sd卡照片的位圖。如何通過MediaStore.Images.Media獲取路徑
String[] projection = {MediaStore.Images.Media._ID,MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.Media._ID);
int count = cursor.getCount();
int image_column_index = cursor.getColumnIndex(MediaStore.Images.Media._ID);
path = new String[count];
bm = new Bitmap[count];
for (int i = 0; i < count; i++) {
cursor.moveToPosition(i);
int id = cursor.getInt(image_column_index);
path[i] //How to get path
bt[i] = MediaStore.Images.Thumbnails.getThumbnail(getApplicationContext().getContentResolver(), id, MediaStore.Images.Thumbnails.MICRO_KIND, null);
}
我已經得到所有照片的縮略圖。 但我想獲得絕對路徑。 我應該在哪裏修改?
關於如何使用它的更多細節? – brian 2012-01-05 03:11:52
int image_column_index = cursor.getColumnIndex(MediaStore.Images.Media._ID); int image_path_index = cursor.getColumnIndex(MediaStore.Images.Media.DATA); // added ... path [i] = cursor.getString(image_path_index); //新增 – idiottiger 2012-01-05 03:16:11
謝謝!我知道了! – brian 2012-01-05 03:18:07