0

私はBlackBerryアプリケーションを開発しています。複数のユーザーの詳細を携帯に保存したい。ユーザーごとに、ユーザー名、名、姓、メールID、電話番号などのデータを保存する必要があります。永続ストアのサンプルコードを教えてください。このコードを使用して、このすべてのデータをベクターに保存し、後で取得できます。

4

1 に答える 1

3

http://www.miamicoder.com/post/2010/04/13/How-to-Save-BlackBerry-Application-Settings-in-the-Persistent-Storeのリンクから、知っておくべきことのほとんどに回答が得られます。 aspx

以下は、私のプロジェクトの 1 つのコードです。

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();
    }
}
于 2011-01-06T05:57:27.117 に答える