2011-09-20 39 views
1

我是黑莓開發的新手。我正在嘗試申請一個名稱和三個複選框結果(即盒子是否已被選中)。我創建了一個屏幕。但我無法將數據保存在數據庫中,我想到了使用SQLite。在BlackBerry中使用SQLite

請幫助我,告訴我如何繼續,我有一個困惑,我會在哪裏編寫數據庫編碼,即在主屏幕類或我必須創建另一個單獨的類。

這是主屏幕編碼。

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(submitSuccessScreen); 

     } 
} 

回答

0

黑莓爲您的問題提供了一些示例演示,您將在黑莓示例演示中檢查SqliteDemo。