多个sqlite表

时间:2013-12-15 07:34:29

标签: android sqlite

我想在单个数据库中创建一个多表。但我从logcat得到这样的错误:没有这样的表。以下是我的代码。

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);

}

0 个答案:

没有答案