开发者

Using SQLite in BlackBerry

I am new to blackberry development. I am trying to make an application where I have to save name and three checkbox results(i.e. whether boxes have checked or not). I have created a screen. But I am not able to save the data in database and I think of using SQLite.

Please help me and tell how can I proceed and I have a confusion that where I will write the coding for database i.e. In the main screen class or I have to create another separate class.

Here is the coding for mainscreen.

package medicine;

import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;


public class EnterSuccessScreen extends MainScreen implements FieldChangeListener{
    EditField nameField; 
    CheckboxField medicineCheckbox1;
    CheckboxField medicineCheckbox2;
    CheckboxField medicineCheckbox3;
    ButtonField submitButton;

    public EnterSuccessScreen(){
        add(new LabelField("Please enter your details:"));
        add(new SeparatorField());
        nameField = new EditField("Medicine Name:", "");
        add(nameField);

        add(new SeparatorField());
        add(new SeparatorField());
        add(new LabelField("Time To Take the Medicine:"));
        medicineCheckbox1 = new CheckboxField(" 9 a.m.", false,Field.FIELD_LEFT);
         add(medicineCheckbox1);

         medicineCheckbox2 = new CheckboxField(" 12 p.m.", false,Field.FIELD_LEFT);
         add(medicineCheckbox2);

         medicineCheckbox3 = new CheckboxField(" 3 p.m.", false,Field.FIELD_LEFT);
         add(medicineCheckbox3);
         add(new SeparatorField());
         submitButton = new ButtonField("Submit", ButtonField.CONSUME_CLICK);
         add(submitButton);
         submitButton.setChangeListener(this);

    }
    public void fieldChanged(Field field, int context){
          if (field == submitButton) {
              submit();
              }
              else{}

        }
        private void submit(){

            SubmitSuccessScreen submitSuccessScreen = new SubmitSuccessScreen();
            UiApplication.getUiApplication().pushScreen(submitSuc开发者_StackOverflow中文版cessScreen);

        }
}


Blackberry gave some sample demos for your problem you check on SqliteDemo in blackberry sample demos.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜