1

If I save a Bitmap called "picture.jpg" in internal storage and some steps later I save another Bitmap called "picture.jpg" too, what happens then? Does the second Bitmap overwrite the first or are there two Bitmaps with the same name then?

L3n95
  • 1,240
  • 2
  • 18
  • 40

1 Answers1

3

It will show you an error, I suggest you could use a dynamic file name or delete it before saving, in the case of dynamic, you could use something like this:

static int fCount = 0;

File file = new File(Environment.getExternalStorageDirectory()
                    + File.separator + "/test" + String.valueOf(fCount++) +".jpg" );

Or

File file = new File(getExternalCacheDir(), "test.jpg" ); if (file.exists()) { boolean deleted = file.delete(); }
user3471194
  • 62
  • 1
  • 3