Get real path from URI, Android KitKat new storage access framework [duplicate]

Before the new gallery access in Android 4.4 (KitKat) I got my real path on the SD card with this method:

public String getPath(Uri uri) {
   String[] projection = { MediaStore.Images.Media.DATA };
   Cursor cursor = managedQuery(uri, projection, null, null, null);
   startManagingCursor(cursor);
   int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
   cursor.moveToFirst();
 return cursor.getString(column_index);
}

Now, the Intent.ACTION_GET_CONTENT return different data:

Before:

content://media/external/images/media/62

Now:

content://com.android.providers.media.documents/document/image:62

How could I manage to obtain the real path on the SD card?

9 Answers
9

Leave a Comment