As I am supporting my app to Kitkat version, now in this the way of retrieve file from gallery was different.
I have preferred this Android Gallery on KitKat returns different Uri for Intent.ACTION_GET_CONTENT for retrieving file from gallery and successfully work but I required Absolute path of that file, I am getting
content://com.android.providers.media.documents/document/image:2505
For 19 below version we used uri different by using that I am getting path this way
Cursor cursor = this.getContentResolver().query(originalUri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String fpath = cursor.getString(column_index);
but in 19 version it will give me null value how to get absolute path of image file which was selected by user.
Thanks
Here is one way to access the Absolute path after selecting file.
After getting data in new URI format for KK(KitKat) like this way
Just extract ID of your document
I hope that this will help you.
Perfectly working solution:
https://github.com/layerlre/Android-Utility-Class/blob/master/utils/ImageFilePath.java
Hope works for you.
Pratik's solution helped me alot. Following is the version which works for me in Kitkat 4.4.2. Three things which i changed are
1) Using content resolver to get the path
2) originalUri.getLastPathSegment().split(":")[1] gives me index out of bound so i'm using index 0 instead.Its been working so far
3) Removed takeflags and check for freshest data as we are filtering the cursor with id.