adrianmcli
adrianmcli

Reputation: 1996

Easiest way to store a value in Phonegap Android

I don't want to set up a database, because all I need to do is store a number from a textbox so that when my app starts, it'll check:

  1. Was there a number set before? (a) If no, show a default number in the textbox. (b) If yes, show that stored number in the textbox.

I need to allow the user to change this number in the textbox and have that persist when the user exits the app and fires it up again.

Any direction? Thanks in advance.

Upvotes: 0

Views: 71

Answers (1)

griegs
griegs

Reputation: 22770

This is essentially a web app right?

You use local storage if it is.

if (localStorage.getItem('storeId') == null) {
    $.mobile.changePage("#pageLocation");
    $("#suburbSelect a").click(function (element) {
        localStorage.setItem('storeId', $(this).attr('storeId'));
        $.mobile.changePage("#page2");
    });
}

The above is jQuery code and localStorage is a HTML 5 thing.

Upvotes: 2

Related Questions