Let me see If I understand it correctly. You want to save a image from camera, but when the user use the camera on the second time, you will loose the first saved image. Is that what you want to fix?
If so, you just need to change the file name that the image will be saved.
I wrote some code below (did not have time to test it). I am using the media.show with the filePath parameter, that will automatically save the camera picture to the file (unfortunately, the Corona simulador does not support it yet, but it will work fine in your device.)
I am using system.TemporaryDirectory but you can use the DocumentsDirectory as well.
If you want just to copy a file from a path to another, you can use this code located here (I am using it copy image files and it works well): http://developer.coronalabs.com/forum/2012/02/10/how-copy-image-file-android-devices
[lua]local imageFileIndex = 1 – variable outside that function that is called to take the picture
function TakePicture() – function that is called to take the picture
local onComplete = function(event)
if event.completed then
– displaying image that was saved
local img = display.newImage(CAMERA_SHOT_FILENAME, system.TemporaryDirectory)
– incrementing the imageFileIndex variable that is used in the image filename
imageFileIndex = imageFileIndex +1
else
– User canceled out
end
end
local CAMERA_SHOT_FILENAME = “camerashot” … imageFileIndex … “.jpg”
local filePath = { baseDir = system.TemporaryDirectory, filename = CAMERA_SHOT_FILENAME }
if media.hasSource( media.Camera ) then
media.show( media.Camera, onComplete, filePath )
else
text.text = “Camera not found.”
end
end[/lua] [import]uid: 181011 topic_id: 33445 reply_id: 133416[/import]