facebook

Creating/Deleting/Reading a *.txt File from Device Storage

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

    MSchlicht
    Member

    Hello guys!

    Lets say I have a Textarea which contains automated generated text. I need 2 buttons where the first one saves all of its content on the storage device into a *.txt file. The second button will then delete this file (if exists). The third thing is that when i force-close my app and re-open it, the app should check when started if this *.txt file exists, if thats true it should read the content and directly fill my Textarea again. I tried several things and snippets but i can’t seem to really get this working…

    Is there someone who can shortly show me the 3 (or more) functions I need to implement in order to archieve ‘save function’?

    Thank you!
    Kind regards,
    Marco

    #349707 Reply

    Code_A
    Member

    Do you need to store in a text file? What about using localStorage instead of messing with files?

    Save Text

    var text = $('$m1-<your-screen>-textArea').val();
    localStorage.setItem("text",text);

    Recall Text

    $('$m1-<your-screen>-textArea').val(localStorage.getItem("text"));

    If you need to use a text file, I would suggest reading up on the PhoneGap File API. Maybe it will help. I have not used.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Creating/Deleting/Reading a *.txt File from Device Storage

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