I am trying to build a database using SQlite while referring to various sites.
Once I created a table and entered the data into the database, I was able to read it from the database, but when I added a new table, I got an error even if I deleted the application or the code.If you don't mind, please let me know.
***********************************************************************
public class MyOpenHelper extensions SQLiteOpenHelper{
public MyOpenHelper (Context context) {
super(context, "NameCommentDB", null, 1);
}
@ Override
public void onCreate (SQLiteDatabase db) {
db.execSQL("create table person("+"
"name text not null, " +
"comment text," +
"time text," +
");");
}
@ Override
public void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
*************************************************************************************
public class MyOpenHelper extensions SQLiteOpenHelper{
public MyOpenHelper (Context context) {
super(context, "NameCommentDB", null, 2);
}
@ Override
public void onCreate (SQLiteDatabase db) {
db.execSQL("create table person("+"
"name text not null, " +
"comment text," +
"time text," +
");");
db.execSQL("create table oasis("+)
"name text not null, " +
"comment text," +
"time text," +
");");
}
@ Override
public void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
*****************************************************************************************
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.building_event);
MyOpenHelper helper=new MyOpenHelper(this);
*** finalSQLiteDatabase db=helper.getReadableDatabase();←
**********************************************************************************
E/SQLiteLog:(1)near")":syntax error
E/AndroidRuntime:FATAL EXCEPTION:main
I don't know why I succeeded with the success code, but
I think the cause is ,
after time text
.
Please delete it and try it.
db.execSQL("create table person("+)
"name text not null, " +
"comment text," +
"time text" +
");");
The same goes for oasis.
© 2024 OneMinuteCode. All rights reserved.