Hi I'm making an application in which I make photos with an application of a camera that I created, and then I store these images in a particular folder (PFC\_Gallery). The problem that I have is that I don't know how to change the name of the images that I store withot overwriting the previous ones. I tried with a variable imgCounter, that increments every time that I make a photo as you can see in the code below, but when I close the app, this variable restarts again from 0 and I overwrite the other photos. If somebody knows any solution to this it will be really helpful.

```
public static int imgCounter = 0;

@Override
public void onPictureTaken(byte[] data, Camera camera) {

    File path = Environment
            .getExternalStoragePublicDirectory(("PFC_Gallery"));
    File file = new File(path, "IMG" + imgCounter + ".jpg");
    imgCounter++;

    try {
        path.mkdirs();
        OutputStream os = new FileOutputStream(file);
        os.write(data);
        os.close();

        MediaScannerConnection.scanFile(this,
                new String[] { file.toString() }, null,
                new MediaScannerConnection.OnScanCompletedListener() {
                    public void onScanCompleted(String path, Uri uri) {
                        Log.i("ExternalStorage", "Scanned " + path + ":");
                        Log.i("ExternalStorage", "-> uri=" + uri);
                    }
                });
    } catch (IOException e) {
        Log.w("ExternalStorage", "Error writing " + file, e);
    }

}

```