繼Android的SQLite數據庫數列的詳細信息列表視圖顯示計數是我嘗試讓應用程序的名稱(KEY_NAME),application_category(KEY_CATEGORY)和application_permissions細節的代碼(KEY_PERM )如何一行具有
但我真正想要的是與應用程序的名稱和類別,以顯示權限(計數)我如何能做到的數量,我在列表視圖
處理
public Cursor queueAll() {
String[] columns = new String[] { KEY_ID, KEY_NAME, KEY_CATEGORY,
"count" + KEY_PERM };
Cursor cursor = sqlitedb.query(MYDATABASE_TABLE, columns, null, null,
KEY_NAME, null, null);
return cursor;
}
顯示它
主要活動
mySQLiteAdapter = new Handle(this);
mySQLiteAdapter.openToWrite();
cursor = mySQLiteAdapter.queueAll();
String[] from = new String[] { Handle.KEY_NAME, Handle.KEY_PERM,
Handle.KEY_CATEGORY };
int[] to = new int[] { R.id.appname, R.id.numbpermcount, R.id.category };
cursorAdapter = new SimpleCursorAdapter(this,
R.layout.activity_main_row, cursor, from, to);
listContent.setAdapter(cursorAdapter);
謝謝你提前。
我試着再次這樣做。
處理器
public static final String KEY_ID = "_id";
public static final String KEY_NAME = "application_name";
public static final String KEY_PACK = "application_package";
public static final String KEY_PERM = "application_permission";
public static final String KEY_LEVEL = "application_level";
public static final String KEY_CATEGORY = "application_category";
public Cursor queueAll() {
String[] columns = new String[] { KEY_ID, KEY_NAME, KEY_CATEGORY,
"count(" + KEY_PERM +")" };
Cursor cursor = sqlitedb.query(MYDATABASE_TABLE, columns, null, null,
KEY_NAME, null, null);
return cursor;
}
主要活動
是同上...
ERROR
02-19 22:51:04.049: E/AndroidRuntime(1192): java.lang.RuntimeException: Unable to start activity ComponentInfo{db.database/db.database.MainActivity}: java.lang.IllegalArgumentException: column 'application_permission' does not exist
不會計數(許可)必須是子查詢嗎? – Sam 2013-02-19 16:57:56
我認爲你的列需要像這樣:String [] columns = new String [] {KEY_ID,KEY_NAME,KEY_CATEGORY, 「count(」+ KEY_PERM +「)」}; – 2013-02-19 16:59:17