I am trying to save the image file into my application's internal storage.
To do this, I wrote the following method which takes the id and bitmap and creates the file of an image, where directory is the class static field of type File.
// Returns thumbnail
private static Bitmap saveBitmapWithThumbnail(long id, Bitmap bitmap) {
    Bitmap thumbnail;
    if(directory == null) {
        ContextWrapper cw = new ContextWrapper(Engine.getContext());
        directory = cw.getDir(DIRECTORY_NAME, Context.MODE_PRIVATE);
        if(!directory.exists()) directory.mkdir();
    }
    saveBitmap(getImageFileName(id), bitmap);
    saveBitmap(getThumbnailFileName(id), thumbnail=makeThumbnail(bitmap));
    return thumbnail;
}
What this method does is to get an id and bitmap and save it's original file and created thumbnail into the internal storage.
The names are generated as [id+".png"] for the original file and [id+"_tn.png"] for the thumbnail file.
saveBitmap() mehtod is the one which is writing the bitmap to the internal storage.
private static void saveBitmap(String fileName, Bitmap bitmap) {
    File imageFile = new File(directory, fileName);
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(imageFile);
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
        fos.close();
    } catch(Exception e) {}
}
It takes the file name (11.png, 11_tn.png, ...) and the bitmap (whether it's original or thumbnail) and makes a file and compress into it's outputstream.
The weird thing is that when I run my application for the first time saving the images, it works great.
It can read and write the images that are stored int the internal storage.
However, after I close my application and run it again, it throws FileNotFoundException with following logs.
W/System.err: java.io.FileNotFoundException: /1.png: open failed: ENOENT (No such file or directory)
W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:458)
W/System.err:     at java.io.FileInputStream.<init>(FileInputStream.java:78)
W/System.err:     at com.google.dotplace.dotplace.data.Image.parseCursor(Image.java:118)
W/System.err:     at com.google.dotplace.dotplace.data.Image.checkDebug(Image.java:74)
W/System.err:     at com.google.dotplace.dotplace.LoadActivity.debugDatabase(LoadActivity.java:77)
W/System.err:     at com.google.dotplace.dotplace.LoadActivity.onCreate(LoadActivity.java:25)
W/System.err:     at android.app.Activity.performCreate(Activity.java:5275)
W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2167)
W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2253)
W/System.err:     at android.app.ActivityThread.access$800(ActivityThread.java:142)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err:     at android.os.Looper.loop(Looper.java:136)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5120)
W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
W/System.err:     at dalvik.system.NativeStart.main(Native Method)
W/System.err: Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
W/System.err:     at libcore.io.Posix.open(Native Method)
W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:442)
W/System.err:   ... 19 more
Only conclusion I can make is that internal storage changes or it's files are delete after my application is closed, but I don't know why.
What I am guessing now is that I have problem with my testing.
I'm testing this as follows.
- Compile and run the project with file insertions and check. 
- Compile and run the project without file insertions and check if 1's data is remaining. 
I am doing this because I did't make any ui of writing or reading files in my app.
My only guess is when I compile the project again, it somehow changes something unique in the context of my application which leads to changed internal storage which I think it's quite nonsense.
Where am I wrong??
 
     
     
    