2013-09-28 100 views
0

我與我的sqlite代碼有這個錯誤,但我不知道該怎麼做,因爲我是一個初學者。這是我的logcat,任何幫助將不勝感激。如果你願意,我可以粘貼更多的代碼。Android 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 [email protected] 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) 

我不是在尋找一個非常具體的答案,我只是想知道我應該尋找解決這個問題。謝謝

編輯:我把下劃線,但現在錯誤是說,表中沒有家庭地址列聯繫人。

+0

我認爲你需要使用一個,每列之間 –

回答

4

而不是mobile number它更好,如果你給你的字段名稱mobile_number(不要給出空間)。移動和號碼可能被視爲兩個獨立的領域。

+0

是的,我忘了看到它...漂亮的手錶 –

+0

謝謝你的答覆,我會做出改變,看看會發生什麼。 – Ogen

+5

在android之外調試SQL查詢更容易,您可以在其中輕鬆修改它們。優秀的工具是http://sqlfiddle.com/ – Strix