I'm looking for a method to save data permanently using PhoneGap
.
LocalStorage
I heard LocalStorage
is not 100% permanent, but is somewhere in the alley.
I wouldn't really like to begin with File I/O, because what I need is to create a database with recipes, and they need to stay.
"Number 3" is what I'm asking about. Any suggestions?
Thanks in advance :)
I'm using the localstorage and this is the best solution to keep saved data. Like you said, it isn't 100% permanent. In my case the localstorage is cleared only if you uninstall the app. Find more info about localstorage with Phonegap http://docs.phonegap.com/en/2.1.0/cordova_storage_storage.md.html#localStorage
You could get more info about localstorage on http://diveintohtml5.info/storage.html
You could use a database as well. You can find info on this at http://docs.phonegap.com/en/2.1.0/cordova_storage_storage.md.html#openDatabase
If you would like to store the data on the device permanently even after the app in uninstalled, you will have to do it in a different way on iOS and android.
On iOS you can use the keychain https://github.com/shazron/KeychainPlugin.
On Android you can use the file plugin, and store the data on the SD card (cordova.file.externalRootDirectory).
In both cases, the data will remain on the device even if the user re-installs the app.
If you are using ionic (or just angular), you can use ng-persist that wraps these two plugins in an angular service with the same API for both ios and android.
More details here http://alexdisler.com/2014/04/23/persist-data-mobile-device-app-removed-uninstalled-cordova-ionic/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With