Android Open Source - AppLevels App Levels D B Helper

From Project

Back to project page AppLevels.


The source code is released under:

Apache License

If you think the Android project AppLevels 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 2013 Nick Iaconis/* w  w w  . ja v*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * Filename:
 * Class:    AppLevelsDBHelper
 * Purpose:    Manages SQLite database creation and update. Tracks database
 *         version for database update triggering.

package com.codefox421.applevels;

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

public class AppLevelsDBHelper extends SQLiteOpenHelper {
  public static final String LOG_TAG = "AppLevelsDBHelp";
  public static final String VOLUME_TABLE = "volume_records";
  public static final String KEY_ID = "id";
  public static final String KEY_PACKAGE = "_id";
  public static final String KEY_VOLUME = "volume";
  private static final String DATABASE_NAME = "applevels_appdata";

  private static final int DATABASE_VERSION = 1;

  // Create database for volume levels
  private static final String VOLUME_DB_CREATE = "create table " + VOLUME_TABLE + " ("
      + KEY_PACKAGE + " text primary key, "
      + KEY_VOLUME + " integer not null);";

  // Constructor
  public AppLevelsDBHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);

  // Called when first created, creates databases tables if they do not exist
  public void onCreate(SQLiteDatabase database) {

  // Called during an update of the database (if you increase the database version)
  public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
        "AppLevels: Upgrading database from version " + oldVersion + " to "
            + newVersion + ", which may destroy data...");
    // TODO: enact database upgrade changes

Java Source Code List