I am trying to get a "text/*" file. I am able to get the file path while I am running the following code in an emulator but not while running it on an actual device with the same SDK version.
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
if (data != null) {
String path = data.getData().getPath();
//String path = uri.getPath();
path = path.substring(path.indexOf(":") + 1);
Toast.makeText(this, "" + path, Toast.LENGTH_SHORT).show();
readsampleData(path);
}
}
}
And my manifest file contains the necessary permissions
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />