嘿所以我正在使用FTS3和Sqlite来更快地搜索我的Android应用程序,但是,当我编辑一个单词或删除一个单词时,它在我的真实数据库上运行正常,但在FTS上,没有任何反应。
当我搜索名称预编辑/更新或删除后,它仍然显示出它在数据库中的含义......
不确定有什么问题,或者我是否需要以不同的方式解决问题,这是我的代码:
/*
* deleting all words from dictionary
*/
public void deleteAllWords(DatabaseWords db_delete) {
Log.d("enter delete in dbhelper",
"enter delete in dbhelper "
+ String.valueOf(db_delete.get_id()));
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_WORDS, KEY_DICTIONARYID + "=?",
new String[] { String.valueOf(db_delete.get_dictionaryId()) });
}
/*
* deleting all words FTS from dictionary
*/
public void deleteAllWords_fts(DatabaseWordsFTS db_delete) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(
TABLE_WORDS_FTS,
KEY_DICTIONARY_ID_FTS + "=?",
new String[] { String.valueOf(db_delete.get_dictionary_id_fts()) });
}
/*
*
*
* /* deleting a dictionary
*/
public void deleteDictionary(DatabaseDictionary dictionary) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_DICTIONARY, KEY_ID + "=?",
new String[] { String.valueOf(dictionary.get_id()) });
}
/*
* deleting a word
*/
public void deleteWord(DatabaseWords db_delete) {
Log.d("enter delete in dbhelper",
"enter delete in dbhelper "
+ String.valueOf(db_delete.get_id()));
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_WORDS, KEY_ID + "=?",
new String[] { String.valueOf(db_delete.get_id()) });
}
/*
* deleting a word FTS
*/
public void deleteWord_fts(DatabaseWordsFTS db_delete) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_WORDS_FTS, KEY_ID + "=?",
new String[] { String.valueOf(db_delete.get_id()) });
}
/*
* updating a word
*/
public int updateWord(DatabaseWords word) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_DICTIONARYID, word.get_dictionaryId());
values.put(KEY_WORD1, word.get_word1());
values.put(KEY_WORD2, word.get_word2());
values.put(KEY_WORD3, word.get_word3());
values.put(KEY_WORD4, word.get_word4());
// updating row
return db.update(TABLE_WORDS, values, KEY_ID + "=?",
new String[] { String.valueOf(word.get_id()) });
}
/*
* updating a word FTS
*/
public int updateWord_fts(DatabaseWordsFTS word_fts) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_DICTIONARY_ID_FTS, word_fts.get_dictionary_id_fts());
values.put(KEY_WORD1_FTS, word_fts.get_word1_fts());
values.put(KEY_WORD2_FTS, word_fts.get_word2_fts());
values.put(KEY_WORD3_FTS, word_fts.get_word3_fts());
values.put(KEY_WORD4_FTS, word_fts.get_word4_fts());
// updating row
return db.update(TABLE_WORDS_FTS, values, KEY_ID + "=?",
new String[] { String.valueOf(word_fts.get_id()) });
}
我将常规的一个放在顶部,有效,FTS的一个是FTS。
在这里,我添加了活动文件
中的更新代码// store in db
// creating word
DatabaseWords db_update = new DatabaseWords(word_id, word_d_id,
w_1_s, w_2_s, w_3_s, w_4_s);
DatabaseWordsFTS db_w_fts = new DatabaseWordsFTS(word_id,
word_d_id, w_1_s, w_2_s, w_3_s, w_4_s);
// insert into db create method in database helper
db.updateWord(db_update);
db.updateWord_fts(db_w_fts);
单词更新但是fts one没有?
答案 0 :(得分:1)
您无法使用where子句中的数值查询/更新/删除FTS表中的行。它仅适用于文本。但是可以将其转换为数字:
SELECT * FROM fts_table WHERE CAST(id AS NUMERIC) = 69