How to Select File on android using Intent

Change the line :

chooseFile.setType("file/*");

to

chooseFile.setType("*/*");

This will help you choose any type of file.


the type of a file is .txt

Then use text/plain as a MIME type. As Ian Lake noted in a comment, file/* is not a valid MIME type.

Beyond that, delete getRealPathFromURI() (which will not work). There is no path, beyond the Uri itself. You can read in the contents identified by this Uri by calling openInputStream() on a ContentResolver, and you can get a ContentResolver by calling getContentResolver() on your Activity.