Android (Studio) FileNotFoundException but File is on SD card -


so sometime ive been trying implement joanzapata's pdfview, from: "http://joanzapata.com/android-pdfview/"

the main focus api-10+ friendly.

no matter keep getting 1 error or another, somehow have project working (apparently) when find pdf file , try , load same code projects sample, following issue.

firstly code:

... //file currentloc = new file(string_pdfloc); ... //file thepdf  = currentloc; //thepdf of type file     if( thepdf != null ) {         log.d("mydebug", "1/3 file not null");         if( thepdf.exists() ) {             log.d("mydebug", "2/3 file exists");             if (thepdf.canread()) {                 log.d("mydebug", "3/3 file can read");                 log.d("mydebug", "thepdf: " + thepdf.getabsolutepath());                  //------ pdf should exist ----------------------                 log.d("mydebug","should load thepdfview");                 //pdfview.fromasset(pdfname)                 log.d("mydebug","thepdfview.fromasset");                 thepdfview.fromasset(thepdf.getabsolutepath() );                 log.d("mydebug","thepdfview.fromasset.load");                 thepdfview.fromasset(thepdf.getabsolutepath() ).load();              } else {                 log.d("mydebug", "file exists, cannot read");             }         }else{             log.d("mydebug", "file != null, !exists");         }     }else{         log.d("mydebug","thepdf, still null");     } 

and error, take note "company" & "projectname" named differently still lower-case charcters, have hidden name.

found pdf file d/mydebug? 1/3 file not null d/mydebug? 2/3 file exists d/mydebug? 3/3 file can read d/mydebug? thepdf: /storage/emulated/0/android/data/com.projectname.company.projectname/files/thisisapdf.pdf d/mydebug? should load thepdfview d/mydebug? thepdfview.fromasset d/androidruntime? shutting down vm w/dalvikvm? threadid=1: thread exiting uncaught exception (group=0x41942da0) e/androidruntime? fatal exception: main process: com.projectname.company.projectname, pid: 9591 java.lang.runtimeexception: unable start activity componentinfo{com.projectname.tpub.projectname/com.projectname.company.projectname.pdfviewactivity}: com.joanzapata.pdfview.exception.filenotfoundexception: /storage/emulated/0/android/data/com.projectname.company.projectname/files/thisisapdf.pdf not exist. ...  caused by: com.joanzapata.pdfview.exception.filenotfoundexception: /storage/emulated/0/android/data/com.projectname.company.projectname/files/thisisapdf.pdf not exist.         @ com.joanzapata.pdfview.pdfview.fromasset(pdfview.java:905)         @     com.projectname.company.projectname.pdfviewactivity.oncreate(pdfviewactivity.java:88) 

here permission have in manifest:

<uses-permission     android:name="android.permission.write_external_storage"     /> 

here gradle(app).build file:

dependencies {     compile filetree(dir: 'libs', include: ['*.jar'])     compile 'com.android.support:appcompat-v7:21.0.3'     compile 'com.android.support:support-v4:21.0.3'     compile 'com.joanzapata.pdfview:android-pdfview:1.0.+@aar' } 

so far can tell, plugin should being brought in, otherwise expect errors such ones have had in past regarding gradle.

any advice welcome, checking often, suggestions can try , respond.

based on reading of the source code, fromasset() reading in asset. try fromfile() instead.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -