Note that there are some explanatory texts on larger screens.

plurals
  1. POMutiple sqlite table
    text
    copied!<p>i'm new in android. i want to create a multiple table in single database. But i get such error from logcat: no such table. Below is my code, please help.</p> <pre><code>private static final String DB_NAME = "MyPlayer"; public static final String TABLE_NAME = "playerTable"; public static final String PlayerName = "name"; public static final String PlayerAge = "age"; public static final String PlayerBorn = "born"; public static final String PlayerWeight = "weight"; public static final String PlayerHeight = "height"; //test public static final String TABLE_ATTACK = "attackTable"; public static final String AttackID = "aid"; public static final String Attack = "attack"; //test public DatabaseHelper(Context context, String name, CursorFactory factory, int version) { super(context, DB_NAME, factory, version); } @Override public void onCreate(SQLiteDatabase db) { // Create a database table String createQuery = "CREATE TABLE " + TABLE_NAME + " (_id integer primary key autoincrement," + PlayerName + ", " + PlayerAge + ", "+PlayerBorn+", "+PlayerWeight+", "+PlayerHeight+",);"; db.execSQL(createQuery); String createQueryA = "CREATE TABLE" + TABLE_ATTACK + "(aid integer primart key, "+Attack+",);";//test db.execSQL(createQueryA);//test } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); db.execSQL("DROP TABLE IF EXISTS " + TABLE_ATTACK);//test onCreate(db); } </code></pre> <p>enter code here</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload