问题描述
- 通过 MediaStore.Images.Media 如何获取路径?
- 我使用下面的代码获取 sd card 相片的 bitmap。
String[] projection = {MediaStore.Images.Media._IDMediaStore.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 pathbt[i] = MediaStore.Images.Thumbnails.getThumbnail(getApplicationContext().getContentResolver() id MediaStore.Images.Thumbnails.MICRO_KIND null);}
我已经获得所有照片的 thumbnail。但是我想想获取绝对路径。要改哪些代码?
解决方案
int fileColum = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);if (cursor.moveToFirst()) { String imageFilePath = cursor.getString(fileColumn); }
时间: 2024-10-17 19:28:47