daily pastebin goal
14%
SHARE
TWEET

Untitled

FaizanAhmed123 Mar 26th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private String saveToInternalStorage(Bitmap bitmapImage){
  2.         ContextWrapper cw = new ContextWrapper(getApplicationContext());
  3.         // path to /data/data/yourapp/app_data/imageDir
  4.         File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
  5.         // Create imageDir
  6.         File mypath=new File(directory,"image.jpg");
  7.  
  8.         FileOutputStream fos = null;
  9.         try {
  10.             fos = new FileOutputStream(mypath);
  11.             // Use the compress method on the BitMap object to write image to the OutputStream
  12.             bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
  13.         } catch (Exception e) {
  14.             e.printStackTrace();
  15.         } finally {
  16.             try {
  17.                 fos.close();
  18.             } catch (IOException e) {
  19.                 e.printStackTrace();
  20.             }
  21.         }
  22.         return directory.getAbsolutePath();
  23.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top