Android Open Source - DroidSweeper D S D B Helper






From Project

Back to project page DroidSweeper.

License

The source code is released under:

MIT License

If you think the Android project DroidSweeper 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 de.nisble.droidsweeper.game.database;
//from   w w w. j a  va2s .  c  o m
import de.nisble.droidsweeper.utilities.LogDog;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import static de.nisble.droidsweeper.game.database.DSDBContract.*;

final class DSDBHelper extends SQLiteOpenHelper {
  private static final String CLASSNAME = DSDBHelper.class.getSimpleName();

  DSDBHelper(Context context) {
    super(context, DB_NAME, null, DB_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    LogDog.i(CLASSNAME, "Creating new database: " + DB_NAME + " Version " + DB_VERSION);
    // Create tables
    db.execSQL(LevelTable.CREATE_TABLE);
    db.execSQL(PlayerTable.CREATE_TABLE);
    db.execSQL(GameTable.CREATE_TABLE);
    // Create views
    db.execSQL(Level4GameView.CREATE_VIEW);
    db.execSQL(Player4GameView.CREATE_VIEW);
    db.execSQL(GamesView.CREATE_VIEW);
    // Insert standard levels
    db.execSQL(LevelTable.INSERT_EASY);
    db.execSQL(LevelTable.INSERT_NORMAL);
    db.execSQL(LevelTable.INSERT_HARD);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    LogDog.i(CLASSNAME, "Updating database from " + oldVersion + " to " + newVersion);
    // Drop tables
    db.execSQL(GameTable.DROP_TABLE);
    db.execSQL(PlayerTable.DROP_TABLE);
    db.execSQL(LevelTable.DROP_TABLE);
    // Drop views
    db.execSQL(Level4GameView.DROP_VIEW);
    db.execSQL(Player4GameView.DROP_VIEW);
    db.execSQL(GamesView.DROP_VIEW);
    // Create new one
    onCreate(db);
  }

  @Override
  public void onOpen(SQLiteDatabase db) {
    super.onOpen(db);
    db.execSQL("PRAGMA foreign_keys=ON;");
  }
}




Java Source Code List

de.nisble.droidsweeper.config.ApplicationConfig.java
de.nisble.droidsweeper.config.Constants.java
de.nisble.droidsweeper.config.GameConfig.java
de.nisble.droidsweeper.config.Level.java
de.nisble.droidsweeper.game.Field.java
de.nisble.droidsweeper.game.GameObserver.java
de.nisble.droidsweeper.game.Game.java
de.nisble.droidsweeper.game.Position.java
de.nisble.droidsweeper.game.database.DSDBAdapter.java
de.nisble.droidsweeper.game.database.DSDBContract.java
de.nisble.droidsweeper.game.database.DSDBGameEntry.java
de.nisble.droidsweeper.game.database.DSDBHelper.java
de.nisble.droidsweeper.game.jni.FieldListener.java
de.nisble.droidsweeper.game.jni.FieldStatus.java
de.nisble.droidsweeper.game.jni.GameStatus.java
de.nisble.droidsweeper.game.jni.MatrixObserver.java
de.nisble.droidsweeper.game.jni.MineSweeperMatrix.java
de.nisble.droidsweeper.game.replay.PlayerObserver.java
de.nisble.droidsweeper.game.replay.Player.java
de.nisble.droidsweeper.game.replay.Recorder.java
de.nisble.droidsweeper.game.replay.Replay.java
de.nisble.droidsweeper.game.replay.TimeStep.java
de.nisble.droidsweeper.gui.DroidSweeperActivity.java
de.nisble.droidsweeper.gui.HighScoreActivity.java
de.nisble.droidsweeper.gui.HighScoreListAdapter.java
de.nisble.droidsweeper.gui.SettingsActivity.java
de.nisble.droidsweeper.gui.grid.FieldDrawables.java
de.nisble.droidsweeper.gui.grid.FieldView.java
de.nisble.droidsweeper.gui.grid.GameGridView.java
de.nisble.droidsweeper.utilities.LogDog.java
de.nisble.droidsweeper.utilities.Timer.java