I am writing a PhoneGap application to work on Android initially.
I am writing it to collect images from the camera and store them in the database (a SQLite database using the HTML5 functionality for databases).
So there are two options, store the images in the database, and store the images on the SD card and reference them by filename.
So storing them on the SD card, how can I stop someone deleting them? I can’t right, I mean they could remove the SD card too.
Storing them in the database, the HTML5 spec suggests that databases shouldn’t be bigger than 5 MB, and if they are then the user will be asked if they want to increase the size. But perhaps this is not really an issue for a PhoneGap app?
My recommendation is to store the images as files on the file system. After you take the picture it will be on the SD Card but then you use the File API to move the images to /data/data/{app package name}. That directory is protected and the user is very unlikely to delete the files in that sandbox. It also has the added bonus that when your application is uninstalled that the directory is cleaned up.
This will get you around a host of issues with taking a picture and returning Base64 data. On a lot of phones the camera is so good that the base64 encoded string causes an out of memory error so I tell people to avoid the DATA_URL option whenever then can. Plus, now you store a lot less data in your DB and won’t run into size limits quite so easily.