數據庫類如何從android中的光標檢索對應於特定字段的數據?
public boolean Permissions(String modulename) {
int createable, updateable;
Cursor cursor = db.rawQuery("select * from " + "moduleDesc" + " where "
+ "name" + "='" + modulename + "'", null);
if (cursor.getCount() > 0);
{
createable = cursor.getInt(cursor.getColumnIndex("createable"));
updateable = cursor.getInt(cursor.getColumnIndex("updateable"));
cursor.close();
}
if ((createable == 1) && (updateable == 1)) {
return true;
} else {
return false;
}
}
是我得到的錯誤是可創建cursor.getInt(cursor.getColumnIndex("createable"));
cursorindexoutofbounds雖然光標是有一些價值還是它給這個錯誤! thanx提前
在取數據之前,您需要先移動光標到第一條記錄。 – 2012-07-27 12:27:14