开发者

How to Store Multi-Dimensional Arrays using Phonegap 1.0 for iOS 4.3+

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开发者_Python百科 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!


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')))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜