user1007522
user1007522

Reputation: 8118

Android doesn't find file

I've a file in my Download folder called random.txt and I want to display this in my android app. So I thought I could write this code to get the file path and open it:

String path= Environment.getExternalStorageDirectory()
        .toString() + File.separator;

openPdfIntent(path + "/Download/random.pdf");

But I get the log message that my file doesn't exist. If I browse to the location with my file manager the file is there.

My phone is a HTC one so I don't have a external sdcard.

Upvotes: 0

Views: 76

Answers (3)

user1007522
user1007522

Reputation: 8118

I forgot to give permission in my manifest.

That in combination with

String  pdfFilePath =  Environment.getExternalStorageDirectory()
        .toString() + "/Download/random.pdf";

Upvotes: 1

Siruk Viktor
Siruk Viktor

Reputation: 514

try this:

pdfFilePath = "file://" + Environment.getExternalStorageDirectory()
        .toString() + "/Download/random.pdf";

Upvotes: 0

jrbalrog9
jrbalrog9

Reputation: 11

Remove File.separator from 'path' variable.

Upvotes: 1

Related Questions