0

I am building an iOS App using HTML/CSS/JS(jQuery) + PhoneGap and need to load a set of default records into local storage at each application load for usage in the App. Each record can have an unlimited number of steps, with each step having a set of five sub-steps, each with its own set of vars.

My thought is to store the records as a multi-dimensional object in JSON format in an external file and then insert it into the local database using $.getJSON. Once inserted, I could retrieve the records and parse them using jQuery.

Problem is that I cannot figure out how to store/retrieve multi-dimensional arrays in sqLite. I've also looked at Lawnchair but the documentation is spotty and doesn't seem to do what I need it to.

Is this even possible? Can anyone provide me with a working example or alternative I should look at?

Thank you all!

dSquared
  • 9,725
  • 5
  • 38
  • 54

1 Answers1

0

If you are only targeting iOS then Lawnchair, while a good solution, is overkill. Sqlite will likely be around for a while but it is deprecated for IndexedDB. For now, I would reccomend you just use localStorage.

var data = [[0,0,0],[0,0,0],[0,0,0]]
,   store = window.localStorage

// save data
store.setItem('data', JSON.stringify(data))

// retreive data
console.log(JSON.parse(store.getItem('data')))
  • @Brain: I actually plan on eventually porting the app over to Droid and ended up working with Lawnchair because of the adapters. Great work on the plugin btw!!! I do have two quick follow-up questions: 1. Is it better / faster to have multiple key tables and use `get` Lawnchair function or a single key table and use the query plugin to retrieve data? 2. Is there a way to insert a record to a key table without overriding the existing data within it? Thank you again! – dSquared Aug 19 '11 at 13:59
  • This is the best answer for the question above as stated, even though I ended up using a different method due to porting requirements. – dSquared Aug 19 '11 at 14:05
  • Cool. Thanks! Yes -- `get` will be faster. Again, with the state of phones today you don't really need to worry about it though. Early Androids we did. As to inserting records without overriding... not sure what you mean but I think the answer is no. =) – Brian LeRoux Aug 19 '11 at 16:47
  • @Brain: Been working with the plugin for a bit now and its spot on! Thank you again. – dSquared Aug 22 '11 at 20:02