2013年1月16日 星期三

[SQLite] SQLiteOpenHelper


public class RecordDBHlp extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "record";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME = "moneyRecord";
private static final String COL_ID = "id";
private static final String COL_COST = "cost";
private static final String COL_NAME = "name";

private static final String TABLE_CREATE = String.format("create table %s ( %s integer primary key autoincrement, %s integer not null, %s text )", TABLE_NAME, COL_ID, COL_COST, COL_NAME);

public RecordDBHlp(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(TABLE_CREATE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
};

}

沒有留言:

張貼留言