在黑莓中使用持久存储时空指针

时间:2013-10-29 12:41:39

标签: blackberry persistent

我用这些来存储数据:

value="1";  
FieldChangeListener listenerslider = new FieldChangeListener() {
    public void fieldChanged(Field field, int context) {

        synchronized(store) {
            store.setContents(value); 
            store.commit();
        } 

        Dialog.inform("Success!");
    }
};

这些用于获取该数据

synchronized(store) {
    String currentinfo = (String)store.getContents(); 
    if(currentinfo == null) {
        Dialog.inform("error");
    } 
    else {
        edtplasmasodium.setText(currentinfo);   
    }
}

//我在这两个课程中使用过的

  static PersistentObject store;
  static {
       store = PersistentStore.getPersistentObject( 0xa1a569278238dad2L );
  }
为什么?我在第二类中获取数据时获取空指针,或者我是否想使用真实设备来测试该功能?

1 个答案:

答案 0 :(得分:1)

更改if(currentinfo==null)

if(currentinfo.equals(null))