Basically my listview that uses a CursorLoader to load data was displaying fine with my normal table, but once I converted my table to fts3 (to use MATCH for searching) it stopped displaying data.
Table declaration:
public static final String NOTES_SCHEMA="CREATE VIRTUAL TABLE "+TABLE_NAME+" USING fts3("+
"_id INTEGER PRIMARY KEY"+COMMA+NOTE_TITLE+" TEXT"+COMMA+NOTE_TEXT+" TEXT"+COMMA+TRASH_STATUS+" INTEGER DEFAULT 0"+COMMA+TIME+" INTEGER"+");";
onCreateCursorLoader:
case LOADER_NOTELIST_ID:
String[] projection = new String[]{NotesModel.NotesTable._ID, NotesModel.NotesTable.NOTE_TITLE, NotesModel.NotesTable.NOTE_TEXT,NotesModel.NotesTable.TIME,NotesModel.NotesTable.TRASH_STATUS};
String sortOrder = NotesModel.NotesTable.TIME+ " DESC";
String where = NotesModel.NotesTable.TRASH_STATUS+"=0";
CursorLoader cursorLoader = new CursorLoader(getApplicationContext().getApplicationContext(), uri, projection, where, null , sortOrder
);
return cursorLoader;
I also noticed when I removed the where argument, it worked (but i need that argument).
Content Provider:
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
Cursor cursor;
switch (uriMatcher.match(uri)) {
case NOTES_LIST://display the whole list, for main activity
qb.setTables(NotesModel.NotesTable.TABLE_NAME);//set table to be queried
break;
case NOTES_ITEM:
qb.setTables(NotesModel.NotesTable.TABLE_NAME);
qb.appendWhere(NotesModel.NotesTable._ID + " = "+ uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Invalid URI: " + uri);
}
cursor = qb.query(db,projection,selection,selectionArgs,null,null,sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);//observer for loader
return cursor;
}
Any comments or solutions would highly be appreciated.
Aucun commentaire:
Enregistrer un commentaire