I want to select pdf file from phone on button click and display its file name on a text view. till now I have done opening file manager for selecting pdf on button click
<
Add in your getPDFPath
method:
public String getPDFPath(Uri uri){
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(contentUri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
In your case, this code is specifically for documents from DonwloadProvider, for further implementation check Paul Burke answer. I personally use his aFileChooser library to avoid this kind of problems.
Hope this helps!