I use below code to get the bitmap of all sd card photo.
String[] projection = {MediaStore.Images.Media._ID,MediaStore.Images.Media.DATA};
Cursor cursor =
Images.ImageColumns.DATA
is the path
How to use it:
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);
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == yourRequestCode) {
currImageURI = data.getData();
}
}
}
// Convert the image URI to the direct file system path
public String getRealPathFromURI(Uri contentUri) {
String [] proj={MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery( contentUri,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
In Latest OS managed query
is deprecated So use
yourActivity.getContentResolver().query
instead of it, Both uses the same arguments