Getting File From Device On Android, Keeps Stating File Not Found When Trying To Use It
I have an Android app where I am allowing the user to pick a file from the file system, I then get the path and set the path to an EditText and then use this path to open the file
Solution 1:
To use the file I do the following:
getPath()
only has meaning on a Uri
if the scheme is file
. Your scheme is content
.
Replace:
Filefile=newFile(txtPublicKeyPath.getText().toString());
FileInputStreamfis=newFileInputStream(file);
with:
InputStreamfis= getContentResolver().openInputStream(uri);
As a bonus, the replacement works for both file
and content
schemes.
Post a Comment for "Getting File From Device On Android, Keeps Stating File Not Found When Trying To Use It"