For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 6 replies, 2 voices, and was last updated 12 years, 1 month ago by
PBXhowTos.
-
AuthorPosts
-
PBXhowTosMemberI have been searching and cannot find how to save and read from a local file on the device.
Basically I am writing an app to save to an XML file and read from it. Do I need to write a special code to do this or is there a pre-defined settings file to edit?
Please advise.
Thanks!January 30, 2014 at 8:35 am #346532
BrandonMemberYou will most likely need the Phonegap API for the File:
http://docs.phonegap.com/en/3.3.0/cordova_file_file.md.html#FileJanuary 30, 2014 at 8:46 am #346534
PBXhowTosMemberWhat is PhoneGap? I just want to save a local xml file on my device and be able to read from it. Nothing more.
January 30, 2014 at 9:11 am #346536
BrandonMemberPhonegap is the API that Mobione is built on. Javascript does not have the capabilities to write to files by itself.
I forgot to mention that reading the xml file is a lot easier as you can use an Ajax call like so:(Note just a quick Ajax sample, I had nearby, not directly from a Mobione app)
$.ajax({ type: "GET", url: "sites.xml", dataType: "xml", success: function(xml) { $(xml).find('site').each(function(){ var id = $(this).attr('id'); var title = $(this).find('title').text(); var url = $(this).find('url').text(); $('<div class="items" id="link_'+id+'"></div>').html('<a href="'+url+'">'+title+'</a>').appendTo('#page-wrap'); $(this).find('desc').each(function(){ var brief = $(this).find('brief').text(); var long = $(this).find('long').text(); $('<div class="brief"></div>').html(brief).appendTo('#link_'+id); $('<div class="long"></div>').html(long).appendTo('#link_'+id); }); }); } });January 30, 2014 at 9:21 am #346538
PBXhowTosMemberAh thanks for the clarification. Just to note, I am NEW to this product so I am still figuring out the ins and outs. So bottom line is, where/how do I even set specific code to do this type of function.
Some notes to consider:
I have the XML files already to load to the device. (Base load files)
I want to be able to read from these file (Set fields and are the same across all XML files)
Save to said XML files.Is this too complex for this or no?
January 30, 2014 at 9:33 am #346542
BrandonMemberIf you don’t have much experience with Javascript and Programming I would start small. Going through some of the tutorials on the examples forum. All custom code must go into the main sceens xxx_custom.js file, this is the only one that will not get written over in the compiling process.
Working with the PhoneGap API can be a bit tricky, but it will make it where you can do a lot more with your app on a device running as a native app (as opposed to a web app hosted on a server).
If you haven’t looked it over there is a lot of information in the Learning Center: http://www.genuitec.com/mobile/learningcenter.php
January 30, 2014 at 9:57 am #346545
PBXhowTosMemberMy aim for sure is device and not webserver as I don’t want users to have to rely on an Internet connection to read/write to files.
Thanks for the info.
-
AuthorPosts
