I have an activity that when users press “share” on a file it would open my app and start uploading the file. Now this works perfectly with images because the URI returned is for MediaStore. But I want to be able to return the URI from any source such as from ES File Explorer
Here is the current code:
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
How can I make this so instead of MediaStore it will be used for any type of file?
You can’t do that. You can use it for the media store, beacuse the path of those images are stored in the built in SQLite database, but the files on your sd card has no entries in the database.
You can check if the URI’s scheme is content or file, and use different methods to access the file the following way: