java - AndroidPdfViewer - Can not open PDF document from Assets folder -


i've been working this pdf library, trying path pdf file resides, keep getting error. missing here?

checking android device monitor, can see db in database folder reside in assets folder can't find pdf files? please they? check image below

enter image description here

thanks friends, mistake, discovered need read file assets file directory before opening it. working right using code below

` private void copyreadassets(string filename) { assetmanager assetmanager = this.getassets();

    inputstream in = null;     outputstream out = null;     file file = new file(this.getfilesdir(), filename);      try     {         in = assetmanager.open(filename);         out = this.openfileoutput(file.getname(), context.mode_world_readable);          utility.copyfile(in, out);         in.close();         in = null;         out.flush();         out.close();         out = null;     } catch (exception e)     {         log.e("tag", e.getmessage());     }      intent intent = new intent(android.content.intent.action_view);     file dir_file = new file(file.getabsolutepath());      //<-- filetype     string mimetype = utility.getfileminetype(dir_file);      intent.setdataandtype(uri.fromfile(file), mimetype); //"file://" + getfilesdir() + "/abc.pdf"),"application/pdf"     intent.setflags(intent.flag_activity_clear_top);      if(mimetype.equals("application/pdf")){          log.e(tag, uri.fromfile(file).tostring()+" -- "+dir_file);          //mpdfview = new studentpdfviewer();         // mpdfview.display("symfony.pdf", false);          //handle activity         intent intent1 = new intent(this, pdfviewer.class);         intent1.putextra(config.course_file, filename);         //intent1.putextra(sqlitedb.course_name,  listcategory.get(0).getcategory_name());         //intent1.putextras(mbundle);         startactivity(intent1);      }else{          try {             startactivity(intent);         } catch (activitynotfoundexception e) {              toast.maketext(this, "unable load selected course material, please check study studio installation guide install required dependency softwares", toast.length_long).show();         }      }   } 

`

there no "assets folder" on device, , there no "path pdf file reside" on device.

the contents of assets/ folder(s) in app's project stored inside apk. can access assets via assetmanager, , 1 of calling getassets() on handy context, such activity.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -