Hello forum members,
I apologize if this has been asked before, but I did search and was unable to find my question.
I am trying to develop an app which loads images in which the file names are stored in a database. If the file exists I want to display that file, if not I wish to display a standard noimage file. I have had no problems until I try to verify if the images exist. I am using .png files, but I can switch them to .jpg. My issue is that there are several hundred of these files and I want the user to be able to add and remove files by hooking their tablet to their laptop via USB. I want to be able to place the files in the /sdcard/documents folder that lies on the tablet(not an external card, the internal memory). I am having no luck trying to “point” to that location. I can find all sort of help with the system.Documents.Directory, but that is not the correct location. Is Corona capable of opening a file stored at this location, or is this not an option?
My company wants to purchase Corona, but they want to be sure that this is possible, because this will be something we will use on many projects.
Thanks for any info you can give me.
Here is what I have been trying, but I have made many variations with no good results.
function fileExists(fileName)
local exists = false
local fileHandle = io.open( fileName,“r” )
if (fileHandle) then – nil if no file found
io.close(fileHandle)
exists = true
end
return(exists)
end
function storePic(picstring)
local strstart = string.find(picstring,“u54”)
local strend = string.find(picstring,".jpg")
local storestring2 = string.sub(picstring,strstart,strend-1)
local storeimage = “/mnt/sdcard/documents/”…storestring2…".png" --I have tried multiple variations
if fileExists(storeimage) then
return storeimage
else
return “/mnt/sdcard/documents/noimage.png”
end
end [import]uid: 181317 topic_id: 32058 reply_id: 332058[/import]