开发者

Using Persistent Store in BlackBerry

I am developing a BlackBerry applicati开发者_如何转开发on. I want to store the details of multiple users in my mobile. I have to store data like username, first name, last name ,email id ,phone number for each user. Can any one please provide me a sample code for persistent store using which I can store all this data in a vector and retrieve later.


This link should answer most of what you need to know - http://www.miamicoder.com/post/2010/04/13/How-to-Save-BlackBerry-Application-Settings-in-the-Persistent-Store.aspx.

Below is some code from one of my projects.

public class PreferencesStore 
{
    // Not a real key, replace it with your own.    
    private static long m_lTabulaRectaKey = 0l;

    public static Vector getTabulaRectas()
    {
        Vector vecTabulaRectas = new Vector();

        PersistentObject poObject = PersistentStore.getPersistentObject(m_lTabulaRectaKey);

        if(poObject.getContents() != null)
        {
            vecTabulaRectas = (Vector)poObject.getContents();
        }

        return vecTabulaRectas;

    }

    public static void addTabulaRecta(TabulaRecta a_oTabulaRecta)
    {
        Vector vecTabulaRectas = getTabulaRectas();

        vecTabulaRectas.addElement(a_oTabulaRecta);

        PersistentObject poObject = PersistentStore.getPersistentObject(m_lTabulaRectaKey);

        poObject.setContents(vecTabulaRectas);

        poObject.commit();
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜