Reputation: 627
While this question is asked many times in different versions, I have not yet managed to get a clear view as what is a good solution to save a returned json file so it can be used later on the application.
I am using phonegap in combination with JQuery Mobile, I fetch the data as jsonp and I want to save the returned data, in a storage mechanism so I can use that data in my code.
Any ideas, or code are welcomed :)
Upvotes: 0
Views: 2578
Reputation: 17247
You have 2 options in hand
PhoneGap provides you with API to access the sqlite db. So you can just store the JSON as it is in the storage and retrieve it when you want it back.
Check this documentation on how to do this.
All browsers that supports html5 do supports sessionStorage and localStorage. Basic different between these two are is that sessionStorage available in only during the session but localStorage is available as long as browser cache available.
You can store data to sessionStorage or localStorage as below
sessionStorage.myJSONString = '{"name":"Kumar", "age":"22"}'
Read more about html5 storage here.
Upvotes: 2