You Are Here:

Community: Wiki

This page was last modified on 3 August 2009, at 10:30.

How to persist data in a mobile device with widsets

From Forum Nokia Wiki

This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. The article is believed to be still valid for the original topic scope.

Contents

Store class

The Widsets API has a Store class. This class must be used when you want to store and retrieve data in the mobile phone.

The Store class can persist the following classes: ByteArray, InputStream and Value. In this post we'll only see how to persist an instance of the Value class.

Value class

First of all, let's understand the Value class.

An instance of this class can be of the following types: boolean, int, long, String, Binary, Binding (a key-value pair) and List (a list of instances of the Value class).

In our example we'll use both Binding and List types to simulate a data table, with the structure and data showed below:

Image:Tabela-dados.jpg

Example code

//The complete table is represented with a Value instance.
Value tbUsers = [];
 
//The two records.
Value user1 = ["name"=>"Marcos","age"=>;27];
Value user2 = ["name"=>"Fábio","age"=>;26];
 
//Now, we'll add each user into the table.
tbUsers.add(user1);
tbUsers.add(user2);

To get an instance of Store classe you must use the following code:

Store store = getStore();

Now, you can save the data into the table (tbUsers) using the below code:

store.put("tbUsers",tbUsers);

That's all!

If you want to retrieve all data from the table (tbUsers) you can use the below code:

Store store = getStore();
Value tableUsers = store.getValue("tbUsers");
 
for(int i = 0;i < tableUsers.size();i++){
printf(tableUsers.operator_get(i).operator_get("name"));
printf(tableUsers.operator_get(i).operator_get("age"));
}

Conclusion

The Store class is very easy to use, mainly for whom already know the FlashLite technology. The class StoredObject of the FlashLite API is very similiar to the Store class of Widsets API.

This post was originaly published on [Web Runtime Effort]

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ