Reputation: 1581
I want to know how we can convert content:// to file://. In my application I implement custom Content Provider and now I want to convert content: // to file://.
Code:
content://com.abc.provider.local.file/mail/attachment/1.jpg want to convert to file://
String contentPath = LocalFileProvider.MAIL_FILE_URI + picture.getFileName();
Uri photoPath = Uri.parse(contentPath);
Upvotes: 0
Views: 245
Reputation: 13785
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);
}
Upvotes: 1