facebook

Save/Read from Local on device

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #346529 Reply

    PBXhowTos
    Member

    I 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!

    #346532

    Brandon
    Member

    You will most likely need the Phonegap API for the File:
    http://docs.phonegap.com/en/3.3.0/cordova_file_file.md.html#File

    #346534

    PBXhowTos
    Member

    What is PhoneGap? I just want to save a local xml file on my device and be able to read from it. Nothing more.

    #346536

    Brandon
    Member

    Phonegap 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);
                    });
                });
            }
        });
    #346538

    PBXhowTos
    Member

    Ah 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?

    #346542

    Brandon
    Member

    If 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

    #346545

    PBXhowTos
    Member

    My 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.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Save/Read from Local on device

You must be logged in to post in the forum log in