I am trying to read all the photos which I put to the sdcard via Android Device Monitor, I can get the path such as /storage/emulated/0/lemon.jpg
Could you please tell me how I could convert this photo into bitmap?
I am trying to read all the photos which I put to the sdcard via Android Device Monitor, I can get the path such as /storage/emulated/0/lemon.jpg
Could you please tell me how I could convert this photo into bitmap?
If you are targeting Android 4.4 (API level 19) and above you can use Storage Access Framework. Open a document using SAF, get Uri on onActivityResult() and use Uri to open image and turn it into a Bitmap.
Once you have the URI for a document, you can open it or do whatever else you want to do with it.
private Bitmap getBitmapFromUri(Uri uri) throws IOException {
ParcelFileDescriptor parcelFileDescriptor =
getContentResolver().openFileDescriptor(uri, "r");
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
parcelFileDescriptor.close();
return image;
}