How to store pdf file from asset folder to memory card in android
Hi friends I have pdf file in asset folder now i want to store that pdf file to sdcard .and I want to display pdf in webview can anyb开发者_开发问答ody tell how to do?
Thanks
Use AssetManager to get the pdf:
AssetManager assetManager = getAssets();
InputStream inputStream = assetManager.open("your_pdf.pdf");
and then you can write that to the card:
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdcard.getAbsolutePath() + "/where/you/want/it");
dir.mkdirs();
File file = new File(dir, "your_pdf.pdf");
FileOutputStream f = new FileOutputStream(file);
and display it
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(path, "application/pdf");
startActivity(intent);
精彩评论