Save and show picture

I am capturing a photo and saving it to the system.DocumentDirectory.

If I capture a new photo and save it with the same name, the old version of the picture is still displayed, even though the old file is removed 

resultOK, errorMsg = os.remove(thePictureFile);

and the new photo is saved

  local saveOption =           {              filename=pictureSavedAs,              baseDir=system.DocumentsDirectory,              captureOffscreenArea=true,              backgroundColor={0,0,0,0} }  display.save(photo, saveOption)

and when I look in the Project Sandbox - the file has in face been replaced.

I can even open an Overlay window several minutes later, and pass the filename as a parameter and the old version of the file (that is no longer in the Sandbox) is still displayed.

local showDownloadedPicture =  display.newImageRect(sceneGroup,theFileName,system.DocumentsDirectory,totalWidth, totalHeight);

If I however close and re-open the Composer window, the new file is displayed correctly

Is there a “cache” that the Composer window (or Corona) uses, that could be cleared ?

I remember this issue with cover images, when creating tracker for spotify.

I never found out exactly what is going on, but assumed it was some kind of smart ram cache on devices.

The solution for me was to save and load with new filename.

We had to get around this in our games, I can’t find the post where we asked about it but yea if I remember correctly there is a cache for files.

I think we just us os.time() as a suffix for the filename when we save it out so that it’s always different. Not nice but it works.

Thank you both. I do use os.time to save other pictures where the name must not be so specific.

If there is no way around it I will find a workaround using unique names.

I remember this issue with cover images, when creating tracker for spotify.

I never found out exactly what is going on, but assumed it was some kind of smart ram cache on devices.

The solution for me was to save and load with new filename.

We had to get around this in our games, I can’t find the post where we asked about it but yea if I remember correctly there is a cache for files.

I think we just us os.time() as a suffix for the filename when we save it out so that it’s always different. Not nice but it works.

Thank you both. I do use os.time to save other pictures where the name must not be so specific.

If there is no way around it I will find a workaround using unique names.