开发者

Using Sencha Touch, how do I store data in a JSON file?

I'm designing a basic Sencha Touch app in order to get familiar with the environment. What I want to do is have my store (which currently looks like that below) read/write its data to/from a local JSON file. Also, upon loading, I want the store to be able to create the file if one does not currently exist. When I create a new "User" in my app I want the store to be able to write this data to the file.

Before now, my app stored its data using a localstor开发者_StackOverflow社区age proxy, but I want to change that to what I have described above.

App.stores.users = new Ext.data.Store({
    model: 'User',
    autoLoad: true,    
    proxy: {
         type: 'ajax',
         url: 'users.json',
         reader: {
            type: 'json',
            root: 'users'
         }
}

});


This can be only possible if you use phonegap or similar wrappers. As John said you can't use JavaScript to read/write files, but you can make a plugin that will read and write to files.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜