Reputation: 1496
I'm currently developing an application that contains information specific to different geological locations. I am using the Ionic framework with PhoneGap.
Currently I have it so all the information for each area is stored in JSON files. The information is retrieved with each page call and placed dynamically for the user to read. I chose JSON files because they are not hard to manage and I need to be able to allow the user to download areas for offline use. Is JSON an okay route to go for this type of data storage? I have heard about the onboard database memory, but am not sure of any documentation or advantages/disadvantages of using such memory.
Any advice would be appreciated!
Upvotes: 1
Views: 1359
Reputation: 436
There are many ways to store data using ionic/Cordova. While the JSON way you have will do the job, you may run into memory/scalability issues later. Here are a couple of options for you
1) Built-in support for ionic -
window.localStorage['projects'];
http://ionicframework.com/docs/guide/building.html
2) Pouchdb- A portable version of the Apache's Couch database. The best thing here is, it lets you synchronize data back and forth to a remote database.
3) Mozilla LocalForage: Takes care of the backend by abstracting the storage methodology for you. Build specifically for offline storage https://github.com/mozilla/localForage
the advantage of using these are
Upvotes: 4
Reputation: 4677
Since in PhoneGap you code in javascript, JSON is the way to store data, because its easy to handle in javascript, why complicating things.
In PhoneGap I like to use the FileAPI, so I would store the JSON files locally and load them once I need them. Local storage (key/value pairs) is limited to 5MB, while FileAPI is not limited at all, as long as you have enough space you should be able to store it using File API, check the PhoneGap Docs.
Upvotes: 1
Reputation: 1254
I think the best you can do it's to use cordova storage support https://cordova.apache.org/docs/en/3.0.0/cordova_storage_storage.md.html
ngCordova as it's support as well, it haven't been documented yet, but I found a pretty good example of how to use it https://gist.github.com/pbernasconi/ebd1551c8c619fba0a9a
I hope it helps
Upvotes: 0