-2

I am using a library to view and work with PDF's that requires the absolute location of a pdf file.

After researching a bit, i came to know that there is no absolute path of an asset as such. so, where should i store my pdf such that i am able to get the absolute path of it as a string? it is necessary that the pdf be private to my app, so external storage is out of the question. if there is no such place where absolute path can be determined, please tell me the code to COPY an asset to an internal folder?

pblead26
  • 755
  • 1
  • 9
  • 30
  • you can google the code to copy from assets to apk-folder... – PKlumpp Jun 11 '14 at 10:25
  • 2
    Read http://stackoverflow.com/questions/9207203/reading-a-pdf-file-placed-in-assets-folder-in-android , http://stackoverflow.com/questions/17085574/read-a-pdf-file-from-assets-folder, and this http://stackoverflow.com/questions/10137131/how-to-read-pdf-file-in-assets-folder – Robi Kumar Tomar Jun 11 '14 at 10:26
  • may be this can help http://stackoverflow.com/questions/24183472/unable-to-open-pdf-in-android-using-pdfview android-pdf-view library allow to load pdf from asset. like pdfView.fromAsset("myPdf.pdf"); – DCoder Jun 12 '14 at 13:16
  • your problem is already solved here http://stackoverflow.com/questions/24183472/how-to-open-pdf-in-android-using-pdfview – DCoder Jun 12 '14 at 13:26

1 Answers1

1
Try This Code:-

String PATH = "/data/data/" + context.getPackageName() + "/files/";  
String NAME ="Hello.pdf";// file name


InputStream mInput = mContext.getAssets().open(NAME); 
        String outFileName = PATH + NAME; 
        OutputStream mOutput = new FileOutputStream(outFileName); 
        byte[] mBuffer = new byte[1024]; 
        int mLength; 
        while ((mLength = mInput.read(mBuffer))>0) 
        { 
            mOutput.write(mBuffer, 0, mLength); 
        } 
        mOutput.flush(); 
        mOutput.close(); 
        mInput.close(); 
Rutvij
  • 493
  • 3
  • 10