0

I developing kind of image editor and I having a problem with saving final image to the mobile. I'd tried code below for saving the final image.but i have a problem.this is my problem: 1-i save the imageview 2-after that i edit the image view (add some effects or changing background) i wanna save the new image but when i use save button my app save the first image . *i changed the image several time but my app save the first image plz help me

  save.setOnClickListener(new OnClickListener(){

    @Override
    public void onClick(View v) {
        img1.buildDrawingCache();
        Bitmap bp = img1.getDrawingCache();

        String root = Environment.getExternalStorageDirectory().toString();
            File newDir = new File(root + "/insta/pics");    
            newDir.mkdirs();
            Random gen = new Random();
             int n = 10000;
            n = gen.nextInt(n);
            String fotoname = "instaPhoto-"+n+".jpg";
           File file = new File (newDir, fotoname);
            if (file.exists ()) file.delete (); 
                try {
                    FileOutputStream out = new FileOutputStream(file);
                    bp.compress(Bitmap.CompressFormat.JPEG, 100, out);
                   out.flush();
                   out.close();
                   Toast.makeText(getApplicationContext(), " /insta/pics  ", Toast.LENGTH_SHORT ).show();

                } catch (Exception e) {

                }

         }
});

1 Answers1

0

Here is an answer that show exactly how to save an imageVIew to SD card. How to save the image to SD card on button Click android

Community
  • 1
  • 1
guy1820
  • 93
  • 2
  • 10