Skip to content

Instantly share code, notes, and snippets.

@bulentsiyah
Last active May 17, 2018 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bulentsiyah/fa9835d42cf5adca735800b7fc679331 to your computer and use it in GitHub Desktop.
Save bulentsiyah/fa9835d42cf5adca735800b7fc679331 to your computer and use it in GitHub Desktop.
Open pdf files located inside the App (raw folder) Android ---http://www.bulentsiyah.com/open-pdf-files-located-inside-the-app-raw-folder-android/
Open pdf files located inside the App (raw folder) Android
try {
copyFile(getResources().openRawResource(R.raw.yardim),
new FileOutputStream(new File(dirpicture, "yardim_copy.pdf")));
File pdfFile = new File(dirpicture, "yardim_copy.pdf");
Uri path = Uri.fromFile(pdfFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(path, "application/pdf");
startActivity(intent);
} catch (Exception ex) {
ex.toString();
}
public static String dirpicture = Environment.getExternalStorageDirectory()+ "/Bulenttes/";
private void copyFile(InputStream in, OutputStream out) throws IOException { try { byte[] buffer = new byte[1024]; int read; while((read = in.read(buffer)) != -1){ out.write(buffer, 0, read); } }catch(Exception exp){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment