I am selecting a PDF file below
This is the path I am getting (the one in textview)
But I think the the path should be this one(Location)
the code that I used was using intent uri and string as seen below
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("application/pdf");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, REQUEST_CODE);
Log.e("startSearch: ","worked");// this code ends here
//new function(i.e onActivityResult()) starts here
if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
if (data != null) {
final Uri uri = data.getData();
Log.e("on activity result"," yes");
//File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + uri.getPath() +".pdf");
final File file = new File(uri.getPath().toString());
path.setText(file.getPath());
}
}
what should I do to get the right path of the PDF?