开发者

Multiple tables in one SQLite database

Hey guys I've been looking for a topic about how to create 2 tables in same project ? Would you guys please give me some example or some links for me to look for it :)

private static final String DATABASE_NAME = "CAS_DB";
public static final String tbPerson开发者_开发技巧 = "PersonInfo";
public static final String tbColor = "ColorInfo";

what I want is create 2 tables in one database but I can't find any example

Thanks in advance


private static final String PERSON_TABLE_CREATE =
                    "CREATE TABLE " + tbPerson +
                    " (" +
                    PERSON_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    PERSON_NAME + " TEXT);";
private static final String COLOR_TABLE_CREATE =
                    "CREATE TABLE " + tbColor +
                    " (" +
                    COLOR_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    COLOR_NAME + " TEXT);";

And in onCreate method of your database helper:

public void onCreate(SQLiteDatabase db) {
            mDatabase = db;
            mDatabase.execSQL(PERSON_TABLE_CREATE);
            mDatabase.execSQL(COLOR_TABLE_CREATE);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜