============ Problem Description ============
I created two new databases in the program, "Book.db" and "book4.db", then added a data table "Localbook" and "Localbook4" respectively, and the result is that both tables can be created when the program runs, but when I insert data into a table, Another table can not be inserted (empty table, no error), solve!
Here is the code for my two Sqliteopenhelper classes:
First Class of Localbook:
Import Android.content.Context;
Import Android.database.sqlite.SQLiteDatabase;
Import Android.database.sqlite.SQLiteOpenHelper;
public class Localbook extends Sqliteopenhelper {
private static String database_name = "BOOK.DB";
private static int database_version = 1;
Private String Path = "path";
Private String type = "type";
Public Localbook (Context context) {
Super (context, database_name, NULL, database_version);
}
@Override
public void OnCreate (Sqlitedatabase db) {
String sql = "CREATE TABLE" + "Localbook" + "(parent text NOT NULL," + PATH
+ ' text not NULL, ' + TYPE + ' text NOT NULL '
+ ", now text isn't null, ready)";
Db.execsql (SQL);
}
@Override
public void Onupgrade (sqlitedatabase db, int oldversion, int newversion) {
TODO auto-generated Method Stub
Db.execsql ("drop table Localbook");
OnCreate (DB);
}
}
The second class of LOCALBOOK4:
Import Android.content.Context;
Import Android.database.sqlite.SQLiteDatabase;
Import Android.database.sqlite.SQLiteOpenHelper;
public class LocalBook4 extends Sqliteopenhelper {
private static String database_name = "BOOK4.DB";
private static int database_version = 1;
Private String Path = "path";
Private String type = "type";
Public LocalBook4 (Context context) {
Super (context, database_name, NULL, database_version);
}
@Override
public void OnCreate (Sqlitedatabase db) {
String sql = "CREATE TABLE" + "Localbook4" + "(parent text NOT NULL," + PATH
+ ' text not NULL, ' + TYPE + ' text NOT NULL '
+ ", now text isn't null, ready)";
Db.execsql (SQL);
}
@Override
public void Onupgrade (sqlitedatabase db, int oldversion, int newversion) {
TODO auto-generated Method Stub
Db.execsql ("drop table Localbook4");
OnCreate (DB);
}
}
============ Solution 1============
Did you insert the code to see it?
Android SQLite questions about datasheets