我正在开发一个黑莓应用程序。我想在我的手机中存储多个用户的详细信息。我必须为每个用户存储用户名、名字、姓氏、电子邮件 ID、电话号码等数据。谁能给我一个持久存储的示例代码,我可以使用它将所有这些数据存储在一个向量中并稍后检索。
问问题
1138 次
1 回答
3
此链接应回答您需要了解的大部分内容 - http://www.miamicoder.com/post/2010/04/13/How-to-Save-BlackBerry-Application-Settings-in-the-Persistent-Store。 .aspx _
下面是我的一个项目中的一些代码。
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 回答