以下是我尝试获取应用程序名称 (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;
}
主要活动
和上面一样。。。
错误
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