E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaa1d1780
D/EGL_emulation: eglMakeCurrent: 0xae494780: ver 2 0 (tinfo 0xae4b0400)
E/SQLiteLog: (1) AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.harshpatel.asktoaexpert, PID: 14728
android.database.sqlite.SQLiteException: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY (code 1): , while compiling: CREATE TABLE IF NOT EXISTS UserTable(id PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR, email VARCHAR, password VARCHAR);
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)
at com.example.harshpatel.asktoaexpert.signupfarmer.SQLiteTableBuild(signupfarmer.java:79)
at com.example.harshpatel.asktoaexpert.signupfarmer$1.onClick(signupfarmer.java:52)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
答案 0 :(得分:1)
您需要指定ID的列类型,主键 自动 非空约束:
尝试
id INTEGER PRIMARY KEY AUTOINCREMENT
而不是
id PRIMARY KEY AUTOINCREMENT NOT NULL