Android Open Source - bodyapps-android Database Handler






From Project

Back to project page bodyapps-android.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project bodyapps-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (c) 2014, Fashiontec (http://fashiontec.org)
 * Licensed under LGPL, Version 3/* ww  w.  j a  v  a  2  s .  co  m*/
 */

package fossasia.valentina.bodyapp.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 *Creates all the tables in DB and handles DB.
 */
public class DatabaseHandler extends SQLiteOpenHelper{
    public static final int DATABASE_VERSION = 7;
    public static final String DATABASE_NAME = "BodyApp.db";
    public static DatabaseHandler dbHandler;
    
    
  private DatabaseHandler(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    Log.d("SQLite", "Creating Databases");
    db.execSQL(DBContract.User.SQL_CREATE_ENTRIES);
    Log.d("table", "Created user");
    db.execSQL(DBContract.Person.SQL_CREATE_ENTRIES);
    Log.d("table", "Created person");
    db.execSQL(DBContract.Measurement.SQL_CREATE_ENTRIES);
    Log.d("table", "Created measurement");
    db.execSQL(DBContract.Delete.SQL_CREATE_ENTRIES);
    Log.d("table", "Created delete");
    
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL(DBContract.User.SQL_DELETE_ENTRIES);
    db.execSQL(DBContract.Person.SQL_DELETE_ENTRIES);
    db.execSQL(DBContract.Measurement.SQL_DELETE_ENTRIES);
    db.execSQL(DBContract.Delete.SQL_DELETE_ENTRIES);
    onCreate(db);
    
  }
  
  public static DatabaseHandler getInstance (Context context){
    if(dbHandler==null){
      dbHandler=new DatabaseHandler(context);
    }
    return dbHandler;
  }

}




Java Source Code List

fossasia.valentina.bodyapp.db.DBContract.java
fossasia.valentina.bodyapp.db.DatabaseHandler.java
fossasia.valentina.bodyapp.main.CreateActivity.java
fossasia.valentina.bodyapp.main.GridAdapter.java
fossasia.valentina.bodyapp.main.MainActivity.java
fossasia.valentina.bodyapp.main.MeasurementActivity.java
fossasia.valentina.bodyapp.main.SavedActivity.java
fossasia.valentina.bodyapp.main.SavedAdapter.java
fossasia.valentina.bodyapp.main.SettingsActivity.java
fossasia.valentina.bodyapp.managers.MeasurementManager.java
fossasia.valentina.bodyapp.managers.PersonManager.java
fossasia.valentina.bodyapp.managers.UserManager.java
fossasia.valentina.bodyapp.models.MeasurementListModel.java
fossasia.valentina.bodyapp.models.Measurement.java
fossasia.valentina.bodyapp.models.Person.java
fossasia.valentina.bodyapp.models.User.java
fossasia.valentina.bodyapp.sync.SyncMeasurement.java
fossasia.valentina.bodyapp.sync.SyncUser.java
fossasia.valentina.bodyapp.sync.Sync.java