2
我有一個自動完成,其中當我開始輸入時,顯示數據庫中兩列的內容。對自動完成執行過濾
現在,我想perfom這個過濾和我採取了以下梅託德:
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
if (getFilterQueryProvider() != null) { return getFilterQueryProvider().runQuery(constraint); }
String filter="";
if(constraint==null) filter="";
else filter=constraint.toString();
Cursor cursor=db.getCursor(filter);
return cursor;
}
在我的課操縱數據庫的方法是這樣的:
public Cursor getCursor(String prefix) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
String[] args = {prefix};
queryBuilder.setTables(TABLE_2);
String[] asColumnsToReturn = new String[] {"route","user_id"};
Cursor mCursor = queryBuilder.query(db,asColumnsToReturn,null, args, null, null,null);
int idcol = mCursor.getColumnIndexOrThrow(KEY_ROUTE);
int kwcol = mCursor.getColumnIndexOrThrow(KEY_USER_ID);
while(mCursor.moveToNext()) {
String id = mCursor.getString(idcol);
String kw = mCursor.getString(kwcol);
Log.d(id,kw);
}
return mCursor;
}
問:爲什麼在我的自動完成功能中不顯示任何內容?
這是我的logcat的樣子:
05-01 09:28:59.207: WARN/Filter(366): An exception occured during performFiltering()!
05-01 09:28:59.207: WARN/Filter(366): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x3114b8
05-01 09:28:59.207: WARN/Filter(366): at android.database.sqlite.SQLiteProgram.native_bind_string(Native Method)
05-01 09:28:59.207: WARN/Filter(366): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:178)
05-01 09:28:59.207: WARN/Filter(366): at android.database.sqlite.SQLiteQuery.bindString(SQLiteQuery.java:190)
05-01 09:28:59.207: WARN/Filter(366): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:55)
05-01 09:28:59.207: WARN/Filter(366): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1220)
05-01 09:28:59.207: WARN/Filter(366): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:316)
05-01 09:28:59.207: WARN/Filter(366): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:266)
05-01 09:28:59.207: WARN/Filter(366): at com.server.DBAdapter.getCursor(DBAdapter.java:199)
05-01 09:28:59.207: WARN/Filter(366): at com.server.Server8$ContactListCursorAdapter.runQueryOnBackgroundThread(Server8.java:185)
05-01 09:28:59.207: WARN/Filter(366): at android.widget.CursorFilter.performFiltering(CursorFilter.java:49)
05-01 09:28:59.207: WARN/Filter(366): at android.widget.Filter$RequestHandler.handleMessage(Filter.java:234)
05-01 09:28:59.207: WARN/Filter(366): at
android.os.Handler.dispatchMessage(Handler.java:99)
05-01 09:28:59.207: WARN/Filter(366): at android.os.Looper.loop(Looper.java:123)
05-01 09:28:59.207: WARN/Filter(366): at
android.os.HandlerThread.run(HandlerThread.java:60)