Process: com. Tw. Flag myuniversity, PID: 1890
Java. Lang. RuntimeException: Unable to start the activity ComponentInfo {com. Tw. Flag. Myuniversity/com. Tw. Flag. The myuniversity. Award} : android. Database. Sqlite. SQLiteException: near "TABLEnotes" : syntax error code (1) :, while compiling: CREATE TABLEnotes (_id INTEGER PRIMARY KEY AUTOINCREMENT, content TEXT NOT NULL, time TEXT NOT NULL, mode INTEGER DEFAULT 1)
. An android app. ActivityThread. PerformLaunchActivity (ActivityThread. Java: 2416)
. An android app. ActivityThread. HandleLaunchActivity (ActivityThread. Java: 2476)
. An android app. ActivityThread. - wrap11 (ActivityThread. Java)
An android. App. ActivityThread $H.h andleMessage (ActivityThread. Java: 1344)
An android. OS. Handler. DispatchMessage (Handler. Java: 102)
. An android OS. Stars. Loop (148). Which Java:
. An android app. ActivityThread. Main (5417) ActivityThread. Java:
The at Java. Lang. Reflect. Method. Invoke (Native Method)
At com. Android. Internal. OS. $MethodAndArgsCaller ZygoteInit. Run (ZygoteInit. Java: 726)
At com. Android. Internal. OS. ZygoteInit. Main (ZygoteInit. Java: 616)
Under Caused by: android. Database. Sqlite. SQLiteException: near "TABLEnotes" : syntax error code (1) :, while compiling: CREATE TABLEnotes (_id INTEGER PRIMARY KEY AUTOINCREMENT, content TEXT NOT NULL, time TEXT NOT NULL, mode INTEGER DEFAULT 1)
Code like this:
Package com. Tw. Flag. Myuniversity;
The import android. The content. The Context;
The import android. Database. Sqlite. SQLiteDatabase;
The import android. Database. Sqlite. SQLiteOpenHelper;
Public class NoteDataBase extends SQLiteOpenHelper {
Public static final String TABLE_NAME="notes";
Public static final String CONTENT="CONTENT";
Public static final String ID="_id";
Public static final String TIME="TIME";
Public static final String MODE="MODE";
Public NoteDataBase Context (Context) {
Super (context, "notes", null, 1);
}
{//public NoteDataBase Context (Context) super (Context, "notes", null, 1); }
@ Override
Public void onCreate (SQLiteDatabase db) {
Db. ExecSQL (" CREATE TABLE "+ TABLE_NAME
+ "("
+ ID + "INTEGER PRIMARY KEY AUTOINCREMENT,"
+ CONTENT + "TEXT NOT NULL,"
+ TIME + "TEXT NOT NULL,"
+ MODE + "INTEGER DEFAULT 1)"
);
}
@ Override
Public void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
CodePudding user response:
Put a blank space at the end of the create table and table nameCodePudding user response:
The CREATE TABLEnotes (_id INTEGER PRIMARY KEY AUTOINCREMENT, content TEXT NOT NULL, time TEXT NOT NULL, mode INTEGER DEFAULT 1)CodePudding user response:
How positioning problem: print your SQL statements together, look at where the wrongCodePudding user response: