public String getRealPathFromURI(final Uri contentUri) { String absFile = null; final String[] proj = { MediaStore.Images.Media.DATA }; final ContentResolver cr = getContentResolver(); if (cr == null) return null; final Cursor cursor = cr.query(contentUri, proj, null, null, null); if (cursor.moveToFirst()) { final int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); absFile = cursor.getString(columnIndex); } cursor.close(); return absFile; }Based on https://stackoverflow.com/questions/12714701/deprecated-managedquery-issue
Programming Tips - Android: java.lang.SecurityException when calling managedQuery()
Date: 2024jan5
Language: Java
Q. Android: java.lang.SecurityException when calling managedQuery()
A. Also managedQuery() is deprecated.
Here is a better replacement.