안녕하세요 SQLite cursor 에서 값을 추출하려고 하는데 어떻게 해야 할까요..
//임의로 만든 DatabaseHelper class입니다
public Cursor getListContents(){
SQLiteDatabase db = this.getWritableDatabase();
Cursor data = db.rawQuery("SELECT * FROM " + TABLE_NAME, null);
return data;}
ListView listView = (ListView) findViewById(R.id.listView);
DatabaseHelper myDB = new DatabaseHelper(this);
ArrayList<String> thetList = new ArrayList<>();
Cursor data = myDB.getListContents();
EditText editText2 = (EditText) findViewByld(R.id.editText2);
if(data.getCount() == 0){
Toast.makeText(ViewListActivity.this,"DB 가 비었다",Toast.LENGTH_SHORT).show();
} else{
while(data.moveToNext()){
thetList.add(data.getString(1));
ListAdapter listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,thetList);
listView.setAdapter(listAdapter);
//이 부분이 제가 확인하고 싶은 부분인데 오류가 계속 뜨고있습니다..
editText2.setText(data.getCount());
editText2.setText(data.getString(1));
}
}
제발 도와주세요 오류가 뜹니다.