G7 : SQLite and ListActivity
也不想說啥了,這里記錄一下這兩天被Android下的SQLite+ListActivity一起殘害的教訓。。。
1. SQLite表中的列名一定要用小寫(這個真的害死我了);
2. ListActivity通過SimpleCursorAdapter綁定SQLite時,Cursor對應的query()函數一定要查詢全部的列,哪怕不用(別問問為什么,我也不知道。。。);

String col[] = new String[] { TABLE_COLUMN_ID, TABLE_COLUMN_STRING, TABLE_COLUMN_INTEGER };
Cursor cursor = db.query(TABLE_NAME_TEST, col, null, null, null, null, null, null);

ListAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, new String[] { DBAccess.TABLE_COLUMN_STRING, DBAccess.TABLE_COLUMN_INTEGER }, new int[] { android.R.id.text1, android.R.id.text2});3. 用2.3版本的emulator調試比較好,輸出的log比2.1的多(要是不換個,我還真找不到上面兩個問題);
posted on 2011-07-14 16:51 codejie 閱讀(390) 評論(2) 編輯 收藏 引用 所屬分類: 隨筆而已 、G7
String col[] 

