MuPDFViewer
MuPDFViewer copied to clipboard
can you help me
I want to read a pdf file from assets folder
Thanks...
In ChoosePDFActivity in this onListItemClick method, you can find some codes like this
Uri uri = Uri.parse(mFiles[position].getAbsolutePath());
......
intent.setData(uri);
at line 208, you can copy the file from assets folder to SD and then read the pdf file from sd. You can use these codes to copy file from assets to sd
private void copyDBToSD() {
InputStream myInput;
OutputStream myOutput;
try {
myOutput = new FileOutputStream(
Environment.getExternalStorageDirectory() + "/"
+ "filename.pdf");
myInput = this.getAssets().open("filename.pdf");
byte[] buffer = new byte[1024];
int length = myInput.read(buffer);
while (length > 0) {
myOutput.write(buffer, 0, length);
length = myInput.read(buffer);
}
myOutput.flush();
myInput.close();
myOutput.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}