Android Open Source - HeadphoneController H C Db Helper






From Project

Back to project page HeadphoneController.

License

The source code is released under:

GNU General Public License

If you think the Android project HeadphoneController 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

package ca.mbabic.headphonecontroller.db;
/*from ww  w . ja va  2 s  .com*/
import java.util.ArrayList;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Call extending SQLiteOpenHelper implementing database creation and
 * table creation statements.
 * @author Marko Babic
 */
public class HCDbHelper extends SQLiteOpenHelper {

  /**
   * Db version number.
   */
  private static final int DB_VERSION = 1;
  
  public HCDbHelper(Context context, String name) {
    super(context, name, null, DB_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    executeCreationStatements(db);    
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    
  }
  
  /**
   * Executes table creation statement.
   * @param db
   *     The database instance on which to execute the commands.
   */
  private void executeCreationStatements(SQLiteDatabase db) {

    HCDbTable table;
    
    // Create CallState table and insert default values.
    table = new HCCallStateTable();
    table.onCreate(db);
    
    for (ContentValues cv : table.getDefaultValues()) {
      
      db.insert(table.getTableName(), null, cv);
      
    }
    
    // Create Command table.
    table = new HCCommandTable();
    table.onCreate(db);
    
    for (ContentValues cv : table.getDefaultValues()) {
      
      db.insert(table.getTableName(), null, cv);
      
    }
    
    // Create InputSequence table.
    table = new HCInputSequenceTable();
    table.onCreate(db);
    
    for (ContentValues cv : table.getDefaultValues()) {
      
      db.insert(table.getTableName(), null, cv);
      
    }
    
    // Create table encoding which commands can be called from which
    // call states.
    table = new HCCommandCallStateTable();
    table.onCreate(db);
    
    for (ContentValues cv : table.getDefaultValues()) {
      
      db.insert(table.getTableName(), null, cv);
      
    }
    
    
    // Create table encoding which commands are set for each input sequence
    // given a call state.
    table = new HCInputSequenceCommandsTable();
    table.onCreate(db);
    
    for (ContentValues cv : table.getDefaultValues()) {
      
      db.insert(table.getTableName(), null, cv);
      
    }

  }

}




Java Source Code List

ca.mbabic.headphonecontroller.ConfigurationFragment.java
ca.mbabic.headphonecontroller.HCApplication.java
ca.mbabic.headphonecontroller.HomeActivity.java
ca.mbabic.headphonecontroller.SelectCommandActivity.java
ca.mbabic.headphonecontroller.commands.CommandExecutor.java
ca.mbabic.headphonecontroller.commands.HCCommandContext.java
ca.mbabic.headphonecontroller.commands.HCCommandFactory.java
ca.mbabic.headphonecontroller.commands.HCCommand.java
ca.mbabic.headphonecontroller.commands.MuteMusicCommand.java
ca.mbabic.headphonecontroller.commands.NoOpCommand.java
ca.mbabic.headphonecontroller.commands.PlayPauseCommand.java
ca.mbabic.headphonecontroller.commands.PreviousCommand.java
ca.mbabic.headphonecontroller.commands.SkipCommand.java
ca.mbabic.headphonecontroller.configuration.HCConfigAdapter.java
ca.mbabic.headphonecontroller.configuration.HCConfigConstants.java
ca.mbabic.headphonecontroller.db.DbHelper.java
ca.mbabic.headphonecontroller.db.HCCallStateTable.java
ca.mbabic.headphonecontroller.db.HCCommandCallStateTable.java
ca.mbabic.headphonecontroller.db.HCCommandTable.java
ca.mbabic.headphonecontroller.db.HCDbAdapter.java
ca.mbabic.headphonecontroller.db.HCDbHelper.java
ca.mbabic.headphonecontroller.db.HCDbTable.java
ca.mbabic.headphonecontroller.db.HCInputSequenceCommandsTable.java
ca.mbabic.headphonecontroller.db.HCInputSequenceTable.java
ca.mbabic.headphonecontroller.models.HCCmd.java
ca.mbabic.headphonecontroller.models.HCInputSequence.java
ca.mbabic.headphonecontroller.services.MediaButtonListenerService.java
ca.mbabic.headphonecontroller.services.MediaButtonReceiver.java
ca.mbabic.headphonecontroller.services.MediaStateChangeReceiver.java
ca.mbabic.headphonecontroller.statemachine.FourPressState.java
ca.mbabic.headphonecontroller.statemachine.HCStateMachine.java
ca.mbabic.headphonecontroller.statemachine.HCState.java
ca.mbabic.headphonecontroller.statemachine.InactiveState.java
ca.mbabic.headphonecontroller.statemachine.OnePressState.java
ca.mbabic.headphonecontroller.statemachine.ThreePressState.java
ca.mbabic.headphonecontroller.statemachine.TwoPressState.java
ca.mbabic.headphonecontroller.views.CommandAdapter.java