我见过这个question并且在我的情况下没有给我回答。
我正在使用ready库(SQLiteAssetHelper)从资产forder复制SQLite数据库并从data / data / [package] / databases /打开该数据库。现在我想获得3个连接表的值。
条目(ID,ent_seq);感(ID,FK);光泽(ID,FK,郎,值);
使用此方法获取连接表:
public Cursor getJoinedInfo(String lookingFor)
{
Log.d(LOG_TAG, "DB: looking up info");
SQLiteDatabase db=getReadableDatabase();
Cursor cursor;
String query;
query="SELECT " +
" e.id," +
" s.id," +
" s.fk," +
" g.id," +
" g.fk," +
" g.lang," +
" g.lang" +
" FROM entry e" +
" INNER JOIN sense s ON e.id = s.fk" +
" INNER JOIN gloss g ON s.id = g.fk" +
" WHERE g.value like '%"+lookingFor+"%'";
Log.d(LOG_TAG, "DB: query = \n" + query.replace(", ",",\n "));
cursor=db.rawQuery(query,null);
Log.d(LOG_TAG, "DB: query complete");
return cursor;
}
现在它给出了这个错误:
08-09 22:26:16.632:E / AndroidRuntime(9842):java.lang.IllegalArgumentException:列'_id'不存在
我该怎么办?请提出你的建议。
完整的堆栈跟踪:
08-09 23:23:43.015: I/ApplicationPackageManager(11446): cscCountry is not German : SKZ
08-09 23:23:45.031: D/myLogs(11446): d
08-09 23:23:45.031: D/myLogs(11446): DB: looking up info
08-09 23:23:45.109: I/SQLiteAssetHelper(11446): successfully opened database akita
08-09 23:23:45.117: D/myLogs(11446): DB: query =
08-09 23:23:45.117: D/myLogs(11446): SELECT e.id,
08-09 23:23:45.117: D/myLogs(11446): s.id,
08-09 23:23:45.117: D/myLogs(11446): s.fk,
08-09 23:23:45.117: D/myLogs(11446): g.id,
08-09 23:23:45.117: D/myLogs(11446): g.fk,
08-09 23:23:45.117: D/myLogs(11446): g.lang,
08-09 23:23:45.117: D/myLogs(11446): g.lang FROM entry e INNER JOIN sense s ON e.id = s.fk INNER JOIN gloss g ON s.id = g.fk WHERE g.value like '%d%'
08-09 23:23:45.117: D/myLogs(11446): DB: query complete
08-09 23:23:45.117: W/dalvikvm(11446): threadid=1: thread exiting with uncaught exception (group=0x40018578)
08-09 23:23:45.203: E/AndroidRuntime(11446): FATAL EXCEPTION: main
08-09 23:23:45.203: E/AndroidRuntime(11446): java.lang.IllegalArgumentException: column '_id' does not exist
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.support.v4.widget.CursorAdapter.init(CursorAdapter.java:174)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.support.v4.widget.CursorAdapter.<init>(CursorAdapter.java:151)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.support.v4.widget.ResourceCursorAdapter.<init>(ResourceCursorAdapter.java:93)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.support.v4.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:89)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.joericharduz.akita.MainActivity.displayListView(MainActivity.java:77)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.joericharduz.akita.MainActivity.access$0(MainActivity.java:68)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.joericharduz.akita.MainActivity$1.onTextChanged(MainActivity.java:56)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.widget.TextView.sendOnTextChanged(TextView.java:6603)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.widget.TextView.handleTextChanged(TextView.java:6650)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:6794)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.text.SpannableStringBuilder.sendTextChange(SpannableStringBuilder.java:889)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:352)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:269)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:432)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:409)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:28)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:654)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:180)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:120)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:283)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:79)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.os.Handler.dispatchMessage(Handler.java:99)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.os.Looper.loop(Looper.java:130)
08-09 23:23:45.203: E/AndroidRuntime(11446): at android.app.ActivityThread.main(ActivityThread.java:3687)
08-09 23:23:45.203: E/AndroidRuntime(11446): at java.lang.reflect.Method.invokeNative(Native Method)
08-09 23:23:45.203: E/AndroidRuntime(11446): at java.lang.reflect.Method.invoke(Method.java:507)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
08-09 23:23:45.203: E/AndroidRuntime(11446): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
08-09 23:23:45.203: E/AndroidRuntime(11446): at dalvik.system.NativeStart.main(Native Method)