Data passing through the Persistant store between BlackBerry applications

Source: Internet
Author: User
Tags commit

Between BlackBerry native programs, native programs and J2ME programs can pass data through the BlackBerry Persistant Store API.

Note: The advantage of the Persistant store is that it can be persisted. Of course, you can also choose to use RMS, BlackBerry Runtime store transfer parameters, pay attention to their respective characteristics.

Save parameters:

Datacontext.set ("username", Usernamefield.gettext (). Trim ());
Datacontext.commit ();
Take parameters:
String username = (string) datacontext.get ("username");

Datacontext.java Code:

Package util;

Import java.util.Hashtable;

Import Net.rim.device.api.system.PersistentObject;
Import Net.rim.device.api.system.PersistentStore;

public class DataContext {
Private PersistentObject PersistentObject;
Private Hashtable settingstable;
Private long guid=0xbbc7ce874824ab26l;

Public DataContext () {
PersistentObject = Persistentstore.getpersistentobject (GUID);
Synchronized (PersistentObject) {
Settingstable = (Hashtable) persistentobject.getcontents ();
if (null = = settingstable) {
settingstable = new Hashtable ();
Persistentobject.setcontents (settingstable);
Persistentobject.commit ();
}
}
}

public void Reset () {
Synchronized (PersistentObject) {
settingstable = new Hashtable ();
Persistentobject.setcontents (settingstable);
Persistentobject.commit ();
}
}

Public Object get (String key) {
return Settingstable.get (key);
}
public void Set (String key, Object value) {
Settingstable.put (key, value);
}

public void commit () {
Persistentobject.setcontents (settingstable);
Persistentobject.commit ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.