Android Open Source - HomeMovies Log Db Helper






From Project

Back to project page HomeMovies.

License

The source code is released under:

MIT License

If you think the Android project HomeMovies 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 il.co.All4Students.homemovies.util.log.db;
//from  w  ww . ja v  a2  s .c o  m
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.DATABASE_NAME;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.DATABASE_VERSION;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.KEY_DATE;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.KEY_ID;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.KEY_LOG;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.KEY_TAG;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.KEY_TIME;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.LOG_TAG;
import static il.co.All4Students.homemovies.util.log.db.LogDbConstants.TABLE_LOG;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Start DbHelper
 * 
 * @author Arkadi Yoskovitz
 * @date 2013-02-08
 */
public class LogDbHelper extends SQLiteOpenHelper {

  // Constractor
  public LogDbHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  public LogDbHelper(Context context, String name, CursorFactory factory,
      int version) {
    super(context, name, factory, version);
  }

  // Creating Tables
  @Override
  public void onCreate(SQLiteDatabase db) {
    try {
      String CREATE_ITEM_TABLE = ((StringBuilder) new StringBuilder())
          .append("CREATE TABLE IF NOT EXISTS ").append(TABLE_LOG)
          .append(" ( ").append(KEY_ID)
          .append(" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ")
          .append(KEY_DATE).append(" TEXT NOT NULL, ").append(KEY_TIME)
          .append(" TEXT NOT NULL, ").append(KEY_TAG)
          .append(" TEXT NOT NULL, ").append(KEY_LOG)
          .append(" TEXT NOT NULL )").toString();

      db.execSQL(CREATE_ITEM_TABLE);

      Log.e(LOG_TAG, "Create table, table creation OK for line: "
          + CREATE_ITEM_TABLE);
    } catch (SQLiteException ex) {
      Log.e(LOG_TAG, "Create table exception: " + ex.getMessage());
    }
  }

  // Upgrading database
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    try {
      // Drop older table if existed
      db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOG);
      // Create tables again
      onCreate(db);
    } catch (SQLiteException e) {
      Log.d(LOG_TAG, "Table upgrade: " + e.getMessage());
    }
  }
}




Java Source Code List

il.co.All4Students.homemovies.OkCancelBar.java
il.co.All4Students.homemovies.ScreenEdit.java
il.co.All4Students.homemovies.ScreenGridDetail.java
il.co.All4Students.homemovies.ScreenGrid.java
il.co.All4Students.homemovies.ScreenMain.java
il.co.All4Students.homemovies.ScreenPreferences.java
il.co.All4Students.homemovies.ScreenWeb.java
il.co.All4Students.homemovies.app.AppConstants.java
il.co.All4Students.homemovies.app.ApplicationPreference.java
il.co.All4Students.homemovies.app.HomeProjectApplication.java
il.co.All4Students.homemovies.core.ItemCompareRTID.java
il.co.All4Students.homemovies.core.ItemCompareRank.java
il.co.All4Students.homemovies.core.ItemCompareSubject.java
il.co.All4Students.homemovies.core.Item.java
il.co.All4Students.homemovies.util.adapter.ItemListAdapter.java
il.co.All4Students.homemovies.util.adapter.ScreenGridAdapter.java
il.co.All4Students.homemovies.util.app.AppUtil.java
il.co.All4Students.homemovies.util.db.ItemsDbConstants.java
il.co.All4Students.homemovies.util.db.ItemsDbHelper.java
il.co.All4Students.homemovies.util.db.ItemsHandler.java
il.co.All4Students.homemovies.util.dialog.RankDialog.java
il.co.All4Students.homemovies.util.dialog.ShareDialog.java
il.co.All4Students.homemovies.util.email.EmailUtil.java
il.co.All4Students.homemovies.util.image.ExternalStorageLoader.java
il.co.All4Students.homemovies.util.imageWeb.FileCache.java
il.co.All4Students.homemovies.util.imageWeb.ImageLoader.java
il.co.All4Students.homemovies.util.imageWeb.MemoryCache.java
il.co.All4Students.homemovies.util.json.JSONHandler.java
il.co.All4Students.homemovies.util.json.JSONUtilWithTags.java
il.co.All4Students.homemovies.util.json.JSONUtil.java
il.co.All4Students.homemovies.util.log.db.LogDbConstants.java
il.co.All4Students.homemovies.util.log.db.LogDbHelper.java
il.co.All4Students.homemovies.util.log.db.LogHandler.java
il.co.All4Students.homemovies.util.log.util.AppLog.java