我一直在關注使用SQL數據庫的教程,我想我遇到了問題,因爲它已經寫了一段時間了。Android SQL錯誤
例如,它有this.createDatabase必須替換this.openOrCreateDatabase,我發現這與谷歌。還有其他問題,我找不到解決方案:查詢,結果,下一個,setListAdapter都顯示錯誤。
這實際上是這個問題,該教程是爲早期的SDK創建的嗎?有人可以告訴我去哪裏去看看已棄用的方法和他們的替代品,或者指出我應該用什麼替換上面的內容?
道歉我剛剛開始與此,希望你明白我的意思。非常感謝幫助。
編輯: 教程是在這裏:http://www.anddev.org/novice-tutorials-f8/working-with-the-sqlite-database-cursors-t319.html
的問題是在下面的代碼,c.first,results.add,c.next,this.setListAdapter最最後一行有錯誤
if (c.first()) {
int i = 0;
/* Loop through all Results */
do {
i++;
/* Retrieve the values of the Entry
* the Cursor is pointing to. */
String firstName = c.getString(firstNameColumn);
int age = c.getInt(ageColumn);
String ageColumName = c.getColumnName(ageColumn);
/* Add current Entry to results. */
results.add("" + i + ": " + firstName
+ " (" + ageColumName + ": " + age + ")");
} while (c.next());
}
}
} catch (FileNotFoundException e) {
} finally {
if (myDB != null)
myDB.close();
}
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1_small, results));
}}
順便提一下,您正在參考哪個教程?請分享網址.. – TheCottonSilk 2011-01-31 13:33:14