public String getRealPathFromURI(Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index
= cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
Related: Convert between Uri and file path, and load Bitmap from.
hey, nice tutorial :) if convert real path format to content uri.. how? help me please :(
ReplyDeletehello Dananx Papayas,
ReplyDeleteI think it have no perfect solution for your need. In my understanding, uri handle files in MediaStore only. Not all file are kept in Mediastore, so may be you cannot get coresponding uri.
May be you have to implement a method to search mediastore for a specified file.
hello hello Dananx Papayas,
ReplyDeleteplease read Convert between Uri and file path, and load Bitmap from.
Hi , I am able to convert content uri to real path for images.
ReplyDeleteHow to get real path for other formats files like (.txt , .pdf, .xls , .doc) ?
Thanks,
Pratap