我在多个表中使用UNION创建搜索界面,每当我搜索应用程序关闭的单词时,错误表明没有这样的表名,尽管有。我不知道我的代码有什么问题。这是我的代码。
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
if (searchText.getText().toString().length() > 0) {
cursor = db.rawQuery("SELECT _id AS _id, name AS name, desc AS desc FROM comm_acc WHERE name LIKE ? " +
"UNION SELECT _id AS _id, name AS name, desc AS desc FROM comm_filems WHERE name LIKE ? " +
"UNION SELECT _id AS _id, name AS name, desc AS desc FROM comm_psu WHERE name LIKE ? " +
"UNION SELECT _id AS _id, name AS name, desc AS desc FROM comm_shells WHERE name LIKE ? " +
"UNION SELECT _id AS _id, name AS name, desc AS desc FROM comm_sic WHERE name LIKE ? " +
"UNION SELECT _id AS _id,name AS name, desc AS desc FROM comm_stp WHERE name LIKE ?",
new String[]{searchText.getText().toString() + "%" });
adapter = new SimpleCursorAdapter(
getActivity(),
R.layout.search_command_list_item,
cursor,
new String[] {"name", "desc"},
new int[] {R.id.commandName, R.id.commandDesc}, 0);
setListAdapter(adapter);
}
else {
}
}
});
}
这是我的logcat
12-04 01:19:47.145:E / SQLiteLog(19154):( 1)没有这样的表:comm_stp 12-04 01:19:47.177:E / AndroidRuntime(19154):致命异常:主要 12-04 01:19:47.177:E / AndroidRuntime(19154): android.database.sqlite.SQLiteException:没有这样的表:comm_stp(代码 1):,编译时:SELECT _id AS _id,名称AS名称,desc AS desc FROM comm_acc WHERE name LIKE?1 UNION SELECT _id AS _id,名称AS name,desc AS desc FROM comm_filems WHERE name LIKE?1 UNION SELECT _id AS _id,名称AS名称,desc AS desc FROM comm_psu WHERE名称LIKE?1 UNION SELECT _id AS _id,名称AS名称,desc AS desc FROM comm_shells WHERE name LIKE?1 UNION SELECT _id AS _id,name AS name, desc AS desc FROM comm_sic WHERE name LIKE?1 UNION SELECT _id AS _id,名称AS名称,desc AS desc FROM comm_stp WHERE name LIKE?1 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteConnection.nativePrepareStatement(母语 方法)12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:886) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:497) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:58) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteQuery。(SQLiteQuery.java:37)12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253) 12-04 01:19:47.177:E / AndroidRuntime(19154):at com.example.ttg.CommandList $ 1.onTextChanged(CommandList.java:78)12-04 01:19:47.177:E / AndroidRuntime(19154):at android.widget.TextView.sendOnTextChanged(TextView.java:7330)12-04 01:19:47.177:E / AndroidRuntime(19154):at android.widget.TextView.handleTextChanged(TextView.java:7392)12-04 01:19:47.177:E / AndroidRuntime(19154):at android.widget.TextView $ ChangeWatcher.onTextChanged(TextView.java:9006) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:962) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:496) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:674) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:437) 12-04 01:19:47.177:E / AndroidRuntime(19154):at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:333) 12-04 01:19:47.177:E / AndroidRuntime(19154):at com.android.internal.view.IInputConnectionWrapper $ MyHandler.handleMessage(IInputConnectionWrapper.java:77) 12-04 01:19:47.177:E / AndroidRuntime(19154):at android.os.Handler.dispatchMessage(Handler.java:107)12-04 01:19:47.177:E / AndroidRuntime(19154):at android.os.Looper.loop(Looper.java:194)12-04 01:19:47.177: E / AndroidRuntime(19154):at android.app.ActivityThread.main(ActivityThread.java:5391)12-04 01:19:47.177:E / AndroidRuntime(19154):at java.lang.reflect.Method.invokeNative(Native Method)12-04 01:19:47.177:E / AndroidRuntime(19154):at java.lang.reflect.Method.invoke(Method.java:525)12-04 01:19:47.177: E / AndroidRuntime(19154):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:833) 12-04 01:19:47.177:E / AndroidRuntime(19154):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)12-04 01:19:47.177:E / AndroidRuntime(19154):at dalvik.system.NativeStart.main(原生方法)
答案 0 :(得分:0)
因为你的例外是:
no such table: comm_stp
检查您的数据库,您没有任何名称为comm_stp