-1

here i need to save what ever i am dwan that paints and that background iamge into sdcard. tried some method but here save only background image.paints are not saved.can u any one suggest me.

             public void save() {
               String filename5;
                          Date date = new Date(0);
                   SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMddHHmmss");
                          filename5 =  sdf.format(date);


      try{
        mBitmap=BitmapFactory.decodeResource(getResources(),R.drawable.writingsapce);

             String path = Environment.getExternalStorageDirectory().toString();
                OutputStream fOut = null;
                File file = new File(path, "/DCIM/"+filename5+".jpg");
                    fOut = new FileOutputStream(file);

                mBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
                    fOut.flush();
                    fOut.close();

          MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
        } catch (Exception e) {
            e.printStackTrace();
            }}
user1083266
  • 1,751
  • 3
  • 24
  • 26
  • i think here you are not saving the new image you drawn on but just the original one. put your drawing methode so we can tell to you how to proceed ;-) – youssoua Feb 20 '12 at 14:00

1 Answers1

-1

try this snippet, i used it and it worked ;-)

try {
                FileOutputStream out = new FileOutputStream(filename);
               mBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
         } catch (Exception e) {
                e.printStackTrace();
         }

            String path = Environment.getExternalStorageDirectory().toString();
            OutputStream fOut = null;
            File file1 = new File(path, "FitnessGirl"+Contador+".jpg");
            fOut = new FileOutputStream(file1);

            mBitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut);
            fOut.flush();
            fOut.close();

            MediaStore.Images.Media.insertImage(getContentResolver(),file1.getAbsolutePath(),file1.getName(),file1.getName());
youssoua
  • 802
  • 1
  • 11
  • 20