Ogen
Ogen

Reputation: 6709

Android SQLite error with logcat

I'm having this error with my sqlite code but I don't know what to make of it because I am a beginner. Here is my logcat, any help would be appreciated. I can paste more code if you want.

My application just adds a contact to a database.

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)

I'm not looking for a very specific answer I just want to know where I should be looking to fix this problem. Thanks

EDIT: I put the underscores but now the error is saying there is no home address column in table contacts.

Upvotes: 0

Views: 616

Answers (1)

instead of mobile number its better if you give your field name as mobile_number (don't give the space). There might be possibilities where mobile and number can be considered as two separate fields.

Upvotes: 4

Related Questions