Let’s say I want to associate my app with ‘.val’ file. So that when user clicks on ‘.val’ file anywhere on their phone, the app opens and I receive data from the file without using MANAGE_EXTERNAL_STORAGE
permission.
Is there a way to get such data from the intent? Thank you for the help in advance!
Here is the way I am currently getting the file path from the opened file’s intent if that would be helpful
Uri uri = intent.getData();
if(uri!=null) {
String filePath = getFilePathFromUri(this, uri);
Log.d(TAG, "Received file path from intent: " + filePath);
// logic with the path
}
private String getFilePathFromUri(Context context, Uri uri) {
String filePath = null;
if ("content".equals(uri.getScheme())) {
filePath = getDataColumn(context, uri);
} else if ("file".equals(uri.getScheme())) {
filePath = uri.getPath();
}
return filePath;
}
Valeriia Radzivilo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.