Save application data on mobile device

Posted by Valeriy Bashkatov on 23-Jan-2014 00:35

Hello,

I'm looking for an example to save user data directly to a mobile device, such as application settings or custom bookmarks. As I understand, for this purpose commonly used Web SQL. But how to implement this in OE Mobile App Builder?

I would be grateful for a detailed example!

Regards,
Valeriy

Posted by egarcia on 23-Jan-2014 05:56

Hello Valeriy,

A simple way is to use localStorage object and use the set property and set local storage variable actions when defining events from the Mobile App Builder. The Mobile App Builder also allows you to map local storage variables to parameters as part of a request.

You can also use the localStorage object from JavaScript. Here is some more information.

As part of HTML5, there are some few ways that you can store data locally using JavaScript: localStorage, Web SQL and IndexedDB.

Here are some few links with information on them:

- http://html5demos.com/storage

- diveintohtml5.info/storage.html

- www.html5rocks.com/.../todo

- developer.mozilla.org/.../Offline

For the purpose of settings or custom bookmarks, the simplest approach is to use the localStorage object.

The localStorage object allows you to set and retrieve string data based on a key:

localStorage.setItem(key, value)

localStorage.getItem(key)

You can also use the the following syntax:

localStorage[key] = value;

localStorage[key]

Notice that your value can also be an the string representation of an object by using the JSON.stringify() when storing the value and then JSON.parse() when retrieving it.

Examples:

localStorage["currentPage"] = page;

var page = localStorage["currentPage"]

var myAppSettings = {};

myAppSettings.currentPage = page;

myAppSettings.appMode = 2;

localStorage["myAppSettings"] = JSON.stringify(myAppSettings);

myAppSettings = JSON.parse(localStorage["myAppSettings"])

I hope this helps.

All Replies

Posted by egarcia on 23-Jan-2014 05:56

Hello Valeriy,

A simple way is to use localStorage object and use the set property and set local storage variable actions when defining events from the Mobile App Builder. The Mobile App Builder also allows you to map local storage variables to parameters as part of a request.

You can also use the localStorage object from JavaScript. Here is some more information.

As part of HTML5, there are some few ways that you can store data locally using JavaScript: localStorage, Web SQL and IndexedDB.

Here are some few links with information on them:

- http://html5demos.com/storage

- diveintohtml5.info/storage.html

- www.html5rocks.com/.../todo

- developer.mozilla.org/.../Offline

For the purpose of settings or custom bookmarks, the simplest approach is to use the localStorage object.

The localStorage object allows you to set and retrieve string data based on a key:

localStorage.setItem(key, value)

localStorage.getItem(key)

You can also use the the following syntax:

localStorage[key] = value;

localStorage[key]

Notice that your value can also be an the string representation of an object by using the JSON.stringify() when storing the value and then JSON.parse() when retrieving it.

Examples:

localStorage["currentPage"] = page;

var page = localStorage["currentPage"]

var myAppSettings = {};

myAppSettings.currentPage = page;

myAppSettings.appMode = 2;

localStorage["myAppSettings"] = JSON.stringify(myAppSettings);

myAppSettings = JSON.parse(localStorage["myAppSettings"])

I hope this helps.

Posted by Valeriy Bashkatov on 23-Jan-2014 07:04

Thank you, egarcia!

I will try to look into this )

This thread is closed