0

我正在使用持久存储在黑莓应用程序中存储数据。我正在尝试将电话号码存储在持久对象中,但是在存储之后,它会产生null价值。

我在这里发布我的代码:

public static Vector push_data;
public static PersistentObject push_store = null;
public static final long KEY = 0x9df9f961bc333daL;

boolean isNumberVerified;
// PasswordEditField password;

static String verifiedPhoneNumber = "number";
public static String phoneNumber;
static String Number = "number";

public Third() {
    super(Field.USE_ALL_HEIGHT | Field.FIELD_HCENTER);
    System.out.println("******************** Into SplashScreen");

    try {
        bitmap  = Bitmap.getBitmapResource("im.png");
        BitmapField bmpField = new BitmapField(bitmap);
        HorizontalFieldManager hfm = new HorizontalFieldManager();
        hfm.add(bmpField);`

...........

    public void fieldChanged(Field field, int context) {
        if (field == btnNext) {
            final String msg = Util.getRandomNumber();
            checkIsVerified(Number, msg);
        }
    }

    private void checkIsVerified(final String Number, final String msg) {
        Dialog.alert("Verifying  "  + Number);
        if (verifiedPhoneNumber == Number) {
            isNumberVerified = true;
            Dialog.alert("isverified  "  + Number);
            push_store = PersistentStore.getPersistentObject( KEY );
            push_data = (Vector) push_store.getContents();
            if( push_data == null ) {
                push_data = new Vector();
                push_data.addElement("number");
                push_store.setContents( push_data );
                push_store.commit();
                Dialog.alert("isverified  "  + push_data);

                UiApplication.getUiApplication().pushScreen(new spinner());
            } else {
                isNumberVerified = false;
                UiApplication.getUiApplication().pushScreen(new Sms());
            }
        }
4

1 回答 1

0

Try this -

public static String push_data="";
public static PersistentObject push_store; 
public static final long KEY = 0x9df9f961bc33352L;

//For get contents
push_store = PersistentStore.getPersistentObject( KEY );
push_data = (String) push_store.getContents();

//For set contents
push_data=Number;
push_store.setContents( push_data );
push_store.commit();
于 2013-05-01T05:20:53.953 回答