1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| public class RegionDataBase extends SQLiteOpenHelper {
private static final String TAB_REG="table_region";
private static final String COL_ID="idRegion";
private static final String COL_NOM="nomRegion";
private static final String COL_IAMGE="image";
private static final String CREATE_TABLE_REG="CREATE TABLE if not exist "+TAB_REG+" ("
+COL_ID+" INTEGER PRIMARY KEY AUTOINCREMENT,"
+COL_NOM+" TEXT NOT NULL,"
+COL_IAMGE+" TEXT NOT NULL);";
public RegionDataBase(Context context, String name, CursorFactory factory,
int version) {
super(context, name, factory, version);
// TODO Auto-generated constructor stub
}
/*creation de la table region*/
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(CREATE_TABLE_REG);
}
/*chaque mis a jour de la table*/
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
db.execSQL("DROP TABLE"+TAB_REG+";");
onCreate(db);
} |