+ 1
Hello everyone. Anyone know how I can store data in my samartphone? As a small database.
I'm doing an app for Android and I want you to store data in a small database within the device's memory, how can I accomplish this without using a server? The app I'm developing in HTML, CSS and Javascript. How can I retrieve that data when I want it?
1 ответ
+ 2
Use Web Storage.
I wrote some piece of code using that, just today. But I'm not sure how much data you're able to store.
I'm using something like the following code, to store a large string, which I split into an array on retrieval.
To save data:
var data_to_save = "hello";
localStorage.my_data1 = data_to_save;
To retrieve it:
var saved_data = localStorage.my_data1;
First time you run it there will be no "saved_data1" stored.
if ( typeOf (saved_data1) == "undefined"){
/*
set some initial value to saved_data1, or
display some message alerting users.
*/
}
By the way: I'm just learning... not a skilled programmer...
:-)