Android SQLite questions about datasheets

Source: Internet
Author: User

============ 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.