private String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} catch (Exception e) {
Log.e(TAG, "getRealPathFromURI Exception : " + e.toString());
return "";
} finally {
if (cursor != null) {
cursor.close();
}
}
}
Last active
March 29, 2021 10:46
-
-
Save WrathChaos/0ac1e8c86ab737752bec8401d7776414 to your computer and use it in GitHub Desktop.
Android: How to get Real Path from Uri? Article: https://freakycoder.com/android-notes-73-how-to-get-real-path-from-uri-2f78320987f5
I think an entirely new solution is required since the MediaStore.Images.Media.DATA
field is deprecated
I think an entirely new solution is required since the
MediaStore.Images.Media.DATA
field is deprecated
I'm gonna working on it ASAP :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @zunjae, It's been awhile working on Native Android. I'm going to revise it.