0

I want to create a Table the first time a phoneGap App loads, then when the user saves their settings I want to pull data from that table the second time (and every other time) the app is loaded. The part that I'm not sure on is simply having the table created on the initial app load. Any advice on this?

This is a web app, so I'm using jQueryMobile, phoneGap and HTML 5

Josh
  • 431
  • 4
  • 12

1 Answers1

2

Use localstorage, it's easier to create, modify and use. I use it for app settings, user names, passwords, tokens to facebook and twitter and it works great.

localStorage.setItem("FOO","BAR");

var foo = localStorage.getItem("FOO"); // foo = "BAR"

Drew Dahlman
  • 4,952
  • 1
  • 22
  • 34
  • Your right localStorage seems to be a nice solution, thanks for another good answer :). Do you know if there is a set of standards that should be followed for this kind of thing (ie when to use localStorage vs SQLite)? I'm surprised that I can't really find any sort of standard for this kind of app development. – Josh Jan 29 '12 at 20:24
  • :) glad i could help! I don't know of any "standard" for use, but it really depends on what you're needing to do. Honestly I've found that the localStorage system is pretty awesome, you can go beyond storing strings to storing JSON object, arrays, image data. I think that using a SQLLite db could be useful if you have to store a ton of information, still then depending on what you're storing, ls could work. Much easier to use. – Drew Dahlman Jan 29 '12 at 20:30
  • @Josh did you have any problem with this approach?? As I could see (for instance http://stackoverflow.com/questions/9681160/does-ios-5-1-clear-the-localstorage-when-i-close-a-phonegap-app-in-the-multitask), the local storage data is not persistent in some systems – davids Aug 14 '12 at 11:55
  • @davids - this issue has been resolved in more recent versions of Cordova, there are work arounds for older versions http://stackoverflow.com/questions/9664392/phonegap-ios-5-1-and-localstorage/9686136#9686136 but everything should be good from 1.6+ – Drew Dahlman Aug 14 '12 at 15:53
  • @DrewDahlman - great, thanks. Do you know how to login to twitter using phonegap? – dang May 24 '14 at 09:34
  • @dang here's a github repo i made for twitter login. it's a little old but follows the same core idea. https://github.com/DrewDahlman/phoneGapTwitterApp – Drew Dahlman May 24 '14 at 14:21
  • @DrewDahlman - I'm using FB login using inappbrowser. Using childbrowser - wouldn't it be a problem? Also, is there an integrated way to get FB & Twitter login in phonegap? – dang May 24 '14 at 14:48
  • The childbrowser is the old form of the inapp browser. The concept is the same though. – Drew Dahlman May 24 '14 at 17:26