I use below code to get image file path and it thumbnail.
String[] projection = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, MediaStore.Images.ImageColumns.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);
int image_path_index = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
int i;
for(i = 0; i < count; i++) {
cursor.moveToPosition(i);
int id = cursor.getInt(image_column_index);
String p = cursor.getString(image_path_index);
Bitmap b = MediaStore.Images.Thumbnails.getThumbnail(getApplicationContext().getContentResolver(), id, MediaStore.Images.Thumbnails.MICRO_KIND, null);
}
And I try below code to refresh the database after file be modified.
Intent scanIntent = new Intent(Intent.ACTION_MEDIA_MOUNTED);
scanIntent.setData(Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath())));
sendBroadcast(scanIntent);
But while the file number more, it spend time more.
So I want to confirm it finish to after work.
How can I do to know it finish?
Run below:
And define class MediaScannerReceiver: