我試圖創造從表中檢索數據的方法,但我與光標一個問題:Android的數據庫和光標
public ArrayList<Contenu> getTest(){
ArrayList<Contenu> test = new ArrayList<Contenu>();
String query = new String("select valeur from table_contenu");
Cursor c = bdd.rawQuery(query , null);
c.moveToFirst();
while (c.moveToNext())
{
Contenu contenu = new Contenu();
contenu.setValeur(c.getString(c.getPosition())); // bug
test.add(contenu);
}
return test;
日誌貓:
java.lang.IllegalStateException: Couldn't read row 1, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
你是對的,謝謝 – user3244162