daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.i2m.sqliteeval2;
  2.  
  3. import android.content.Context;
  4. import android.database.sqlite.SQLiteDatabase;
  5. import android.database.sqlite.SQLiteOpenHelper;
  6. import android.database.sqlite.SQLiteDatabase.CursorFactory;
  7.  
  8. public class MaBaseSQLite extends SQLiteOpenHelper
  9. {
  10.     private static final String TABLE_EVAL = "tableeval";
  11.     private static final String COL_ID = "ID";
  12.     private static final String COL_NOM = "Nom";
  13.     private static final String COL_PRENOM = "Prenom";
  14.     private static final String COL_AGE = "Age";
  15.     private static final String COL_PROF = "Profession";
  16.    
  17.     private static final String CREATE_BDD = "CREATE TABLE " + TABLE_EVAL + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_NOM + " TEXT NOT NULL, " + COL_PRENOM + " TEXT NOT NULL, " + COL_AGE + " INTEGER, " + COL_PROF + "TEXT NOT NULL);";
  18.    
  19.     public MaBaseSQLite(Context context, String name, CursorFactory factory, int version)
  20.     {
  21.         super(context, name, factory, version);
  22.     }
  23.    
  24.     @Override
  25.     public void onCreate(SQLiteDatabase db)
  26.     {
  27.         // On crŽe la table ˆ partir de la requ�te Žcrite dans la variable CREATE_BDD
  28.         db.execSQL(CREATE_BDD);
  29.     }
  30.    
  31.     @Override
  32.     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
  33.     {
  34.         // On peut faire ce qu'on veut ici, comme supprimer et recrŽer la table, comme �a lorsqu'on change la version les id partent de 0
  35.         db.execSQL("DROP TABLE " + TABLE_EVAL + ";");
  36.         onCreate(db);
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top