Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. package br.org.lsitec.overlaycenter.model;
  2.  
  3. import android.content.Context;
  4. import android.database.sqlite.SQLiteDatabase;
  5. import android.database.sqlite.SQLiteOpenHelper;
  6. import android.provider.BaseColumns;
  7. import android.util.Log;
  8.  
  9. public final class DBTable {
  10.  
  11.     private DBTable() {}
  12.  
  13.     public static class PropertyTable implements BaseColumns {
  14.  
  15.         public static final String TABLE_NAME = "properties";
  16.         public static final String PROP_NAME = "name";
  17.         public static final String PROP_FUNC = "function";
  18.     }
  19.  
  20.     public static class DBController extends SQLiteOpenHelper {
  21.  
  22.         public static final int DB_VERSION = '1';
  23.         public static final String DB_NAME = "properties.db";
  24.  
  25.         public DBController(Context context) {
  26.             super(context, DB_NAME, null, DB_VERSION);
  27.         }
  28.  
  29.         @Override
  30.         public void onCreate(SQLiteDatabase db) {
  31.             db.execSQL(SQL_CREATE_ENTRIES);
  32.         }
  33.  
  34.         @Override
  35.         public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  36.             db.execSQL(SQL_DELETE_ENTRIES);
  37.             onCreate(db);
  38.         }
  39.     }
  40.  
  41.     private static final String SQL_CREATE_ENTRIES = "CREATE TABLE " + PropertyTable.TABLE_NAME +
  42.             " (" + PropertyTable._ID + " INTEGER PRIMARY KEY, " + PropertyTable.PROP_NAME + " TEXT, " +
  43.             PropertyTable.PROP_FUNC + " TEXT)";
  44.  
  45.     private static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS " + PropertyTable.TABLE_NAME;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement