开发者

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

开发者 https://www.devze.com 2023-04-12 09:31 出处:网络
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 JS

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

精彩评论

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

关注公众号