Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String saveToInternalStorage(Bitmap bitmapImage){
- ContextWrapper cw = new ContextWrapper(getApplicationContext());
- // path to /data/data/yourapp/app_data/imageDir
- File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
- // Create imageDir
- File mypath=new File(directory,"image.jpg");
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(mypath);
- // Use the compress method on the BitMap object to write image to the OutputStream
- bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- fos.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return directory.getAbsolutePath();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement