0

我的 sqlite 代码出现此错误,但我不知道该怎么做,因为我是初学者。这是我的 logcat,任何帮助将不胜感激。如果需要,我可以粘贴更多代码。

我的应用程序只是将联系人添加到数据库中。

09-28 06:21:51.772: E/SQLiteLog(1564): (1) near "number": syntax error
09-28 06:21:51.803: E/SQLiteDatabase(1564): Error inserting mobile number=1233456 work address= home number=7658678 home address=123 Fake Street first name=John email address=jsmith@gmail.com last name=Smith work number=54372 notes=
09-28 06:21:51.803: E/SQLiteDatabase(1564): android.database.sqlite.SQLiteException: near "number": syntax error (code 1): , while compiling: INSERT INTO contacts(mobile number,work address,home number,home address,first name,email address,last name,work number,notes) VALUES (?,?,?,?,?,?,?,?,?)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at com.example.contactmanager.DatabaseHandler.addContact(DatabaseHandler.java:80)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at com.example.contactmanager.NewContactActivity$1.onClick(NewContactActivity.java:63)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.view.View.performClick(View.java:4240)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.view.View$PerformClick.run(View.java:17721)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.os.Handler.handleCallback(Handler.java:730)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.os.Looper.loop(Looper.java:137)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at java.lang.reflect.Method.invokeNative(Native Method)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at java.lang.reflect.Method.invoke(Method.java:525)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-28 06:21:51.803: E/SQLiteDatabase(1564):     at dalvik.system.NativeStart.main(Native Method)

我不是在寻找一个非常具体的答案,我只是想知道我应该在哪里解决这个问题。谢谢

编辑:我放了下划线,但现在错误是说表联系人中没有家庭地址列。

4

1 回答 1

4

mobile number如果您将字段名称命名为mobile_number(不要给空间),而不是更好。可能有可能将手机和号码视为两个单独的字段。

于 2013-09-28T10:32:31.103 回答