【发布时间】:2018-08-03 18:30:32
【问题描述】:
我用这些来存储数据:
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 );
}
为什么?我在二等舱中获取数据时得到空指针,或者我应该使用真实设备来测试该功能吗?
【问题讨论】:
-
您能否在商店之后立即进行“提取”以证明其正常运行。
-
currentinfo 显示为空
-
更改为 if(currentinfo.equals(null))
-
干草感谢@TheLittleNaruto 我将其更改为 if(currentinfo.equals(null)) 并完成:)
-
我不明白问题出在哪里。您是说
currentinfo永远为空是一个问题(意外结果)吗?或者,您只是想决定当它为空时该怎么做?
标签: blackberry persistent