代码说找不到文件或目录

时间:2019-06-18 03:50:37

标签: android pdf viewer

当我尝试从内部存储加载pdf时出现错误。就是说找不到文件或目录。这是在我的Android应用程序中。

File myfile= new File(openPDF.this.getFilesDir().getAbsolutePath() +"/"+fileName);

        final PDFView pdfView=findViewById(R.id.pdfView);


      //  pdfView =(PDFView)findViewById(R.id.pdfView);
        // pdfView.fromUri(Uri.parse(Utils.getRootDirPath(this)+"/"+filename))
        // pdfView.fromAsset("aqida1.pdf")

        pdfView.fromFile(myfile)
                .enableSwipe(true) // allows to block changing pages using swipe
                .swipeHorizontal(false)
                .enableDoubletap(true)
                .defaultPage(0)// called after document is rendered for the first time
                .enableAntialiasing(true) // improve rendering a little bit on low-res screens
                .enableAnnotationRendering(true)
                .scrollHandle(new DefaultScrollHandle(getApplicationContext(), false))
                .onRender(new OnRenderListener() {
                    @Override
                    public void onInitiallyRendered(int nbPages, float pageWidth, float pageHeight) {
                        pdfView.fitToWidth();


                    }
                })
                .load();
        pdfView.useBestQuality(true);
        pdfView.getKeepScreenOn();
  

2019-06-18 05:36:58.680 11555-11555 / comechoman.dailynation E / PDF查看:   加载pdf错误       java.io.FileNotFoundException:打开失败:ENOENT(没有这样的文件或目录)           在android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313)           在android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211)           在com.github.barteksc.pdfviewer.source.FileSource.createDocument(FileSource.java:37)           在com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:53)           在com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25)           在android.os.AsyncTask $ 2.call(AsyncTask.java:335)           在java.util.concurrent.FutureTask.run(FutureTask.java:266)           在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)           在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:636)           在java.lang.Thread.run(Thread.java:764)2019-06-18 05:36:58.714 11555-11610 / comechoman.dailynation E / [EGL-ERROR]:   __egl_platform_cancel_buffers:644:surface-> num_buffers(4)2019-06-18 05:37:13.152 274-274 /? E / memtrack_graphic:graphic_memtrack_get_memory   打开/ sys / kernel / debug / ion / clients / 593时出错:权限被拒绝

0 个答案:

没有答案