从SQLite,Android中检索数据时出错

时间:2012-02-25 20:16:56

标签: android sqlite

当我尝试从android中的SQLite中检索一些数据时,模拟器在执行期间停止工作。这是我的代码:

public class StartTest extends Activity {

// Objects And Variables
public HtTester _testclass;
private CommentsDataSource datasource2;
private SQLiteDatabase db;
private String _select;
// User Information Variables
String _c1;
String _c2;
String _c3;
String _c4;
String _c5;
String _c6;
String _pregnant;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.starttest);

    // Casting Controls To variables
    Button _strattest = (Button) findViewById(R.id.btnsendtest);
    final EditText _systolic = (EditText) findViewById(R.id.etsystolic);
    final EditText _diastolic = (EditText) findViewById(R.id.etdiastolic);
    //CheckBox _pregnant = (CheckBox) findViewById(R.id.cbpregnant);
    final TextView _result = (TextView) findViewById(R.id.tvresult);

    //Start Test Button Operation
    _strattest.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            datasource2 = new CommentsDataSource();
            db = datasource2.SQLiteDatabaseget(StartTest.this);
            _select = "SELECT * FROM USERSTABLE WHERE _id=" + getIntent().getExtras().getString("USERID");
            Cursor c1 = db.rawQuery(_select, null);
            _c1 = getString(c1.getColumnIndex("USERC1"));
            _c2 = getString(c1.getColumnIndex("USERC2"));
            _c3 = getString(c1.getColumnIndex("USERC3"));
            _c4 = getString(c1.getColumnIndex("USERC4"));
            _c5 = getString(c1.getColumnIndex("USERC5"));
            _c6 = getString(c1.getColumnIndex("USERC6"));
            _result.setText(_c1 + "," +_c2 + "," +_c3 + "," +_c4 + "," +_c5+ "," +_c6 );
        }
    });
  }
}

错误是:

  

02-25 22:06:43.290:E / AndroidRuntime(850):android.content.res.Resources $ NotFoundException:字符串资源ID#0x8

0 个答案:

没有答案