Mohitt Mohitt - 7 months ago 74
Android Question

Android saving bitmap image temporarily

I am looking out for a way to save a bitmap file temporarily in android file system. The file is required only until it is used as a part of POST request to a server after which I want it to cease to exist. I am looking for the faster way of doing this.

File file = new File(Environment.getExternalStorageDirectory().getPath().toString()+"/ImageDB/" + fileName+".png");
FileOutputStream filecon = new FileOutputStream(file);
sampleResized.compress(Bitmap.CompressFormat.JPEG, 90, filecon);

I am currently using this method.

EDIT: I got my solution from Creating temporary files in Android

        File f3=new File(Environment.getExternalStorageDirectory()+"/inpaint/");
        OutputStream outStream = null;
        File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
    try {
        outStream = new FileOutputStream(file);
        mBitmap.compress(Bitmap.CompressFormat.PNG, 85, outStream);

        Toast.makeText(getApplicationContext(), "Saved", Toast.LENGTH_LONG).show();

       } catch (Exception e) {