GrOOm  0.2
BTS SNIR LaSalle Avignon 2020
GroomSQLite.java
Aller à la documentation de ce fichier.
1 package com.example.groom;
2 
3 import android.content.Context;
4 import android.database.sqlite.SQLiteDatabase;
5 import android.database.sqlite.SQLiteOpenHelper;
6 
7 public class GroomSQLite extends SQLiteOpenHelper
8 {
9  public static final String DATABASE_NAME = "groom.db";
10  public static final int DATABASE_VERSION = 1;
11  private static final String CREATE_BDD_OCCUPANTS =
12  "CREATE TABLE occupants (" +
13  "idOccupant INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," +
14  "nom VARCHAR(45) NULL," +
15  "prenom VARCHAR(45) NULL," +
16  "fonction VARCHAR(45) NULL);";
17  private static final String CREATE_BDD_PREFERENCES =
18  "CREATE TABLE preferences (" +
19  "idPreferences INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," +
20  "groom VARCHAR(45) NULL," +
21  "idPrecedentOccupant INTEGER NOT NULL, " +
22  "FOREIGN KEY (idPrecedentOccupant) REFERENCES occupants (idOccupant);";
23 
24  public GroomSQLite(Context context)
25  {
26  super(context, DATABASE_NAME, null, DATABASE_VERSION);
27  }
28 
29  @Override
30  public void onCreate(SQLiteDatabase db)
31  {
32  db.execSQL(CREATE_BDD_OCCUPANTS);
33  db.execSQL(CREATE_BDD_PREFERENCES);
34  }
35 
36  @Override
37  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
38  {
39  db.execSQL("DROP TABLE occupants;");
40  db.execSQL("DROP TABLE preferences");
41  }
42 }
static final String CREATE_BDD_OCCUPANTS
static final int DATABASE_VERSION
static final String DATABASE_NAME
Definition: GroomSQLite.java:9
void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
void onCreate(SQLiteDatabase db)
GroomSQLite(Context context)
static final String CREATE_BDD_PREFERENCES