Android Open Source - Flippy-Radio Flippy Database Helper






From Project

Back to project page Flippy-Radio.

License

The source code is released under:

Apache License

If you think the Android project Flippy-Radio 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 com.bitflippersanonymous.flippy.db;
/*www  .  j  a va 2s . c  o  m*/
import com.bitflippersanonymous.flippy.domain.PlsEntry.Tags;
import com.bitflippersanonymous.flippy.util.Util;

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


public class FlippyDatabaseHelper extends SQLiteOpenHelper {
  private static final String DATABASE_NAME = "applicationdata.db";
  private static final int DATABASE_VERSION = 6;
  
  private static final String TABLE_ENTRY = FlippyDatabaseAdapter.TABLE_ENTRY;
  private static final String TABLE_KEYWORDS = FlippyDatabaseAdapter.TABLE_KEYWORDS;
  private static final String KEY_ROWID = FlippyDatabaseAdapter.KEY_ROWID;
  
  private static final String [] CREATE_TABLES = { 
    "create table " + TABLE_ENTRY + " ("
    + KEY_ROWID + " integer primary key autoincrement, "
    + Tags.pubDate.name() + " integer",
    
    "create table " + TABLE_KEYWORDS + " ("
    + KEY_ROWID + " integer primary key autoincrement, "
    + Tags.keywords.name() + " text not null);",

    "create table " + TABLE_ENTRY+TABLE_KEYWORDS
    + " (" + TABLE_ENTRY + " integer not null, "
    + TABLE_KEYWORDS + " integer not null, "
    + "PRIMARY KEY (" + TABLE_ENTRY + ", " + TABLE_KEYWORDS + ") );",
  };
  
  private static final String[] TABLES = { TABLE_ENTRY, TABLE_KEYWORDS, TABLE_ENTRY+TABLE_KEYWORDS };

  public FlippyDatabaseHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {

    for ( Tags tag : Tags.values() ) {
      if ( tag == Tags.keywords ) continue;
      if ( tag == Tags.pubDate ) continue;
      CREATE_TABLES[0] += ", " + tag.name() + " text "; 
    }
    CREATE_TABLES[0] += ");";
    
    for ( String table : CREATE_TABLES )
      db.execSQL(table);
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(getClass().getName(),  "Upgrading database from version " + oldVersion + " to "
      + newVersion + ", which will destroy all old data");
    for ( String table : TABLES )
      db.execSQL("DROP TABLE IF EXISTS " + table);
    onCreate(db);
  }

}




Java Source Code List

.PlsAdapter.java
com.bitflippersanonymous.flippy.activity.FlippyAboutActivity.java
com.bitflippersanonymous.flippy.activity.FlippyBaseActivity.java
com.bitflippersanonymous.flippy.activity.FlippyBrowseActivity.java
com.bitflippersanonymous.flippy.activity.FlippyInfoActivity.java
com.bitflippersanonymous.flippy.activity.FlippyMainActivity.java
com.bitflippersanonymous.flippy.activity.FlippyQueueActivity.java
com.bitflippersanonymous.flippy.activity.FlippySearchActivity.java
com.bitflippersanonymous.flippy.activity.FlippySettingsActivity.java
com.bitflippersanonymous.flippy.db.FlippyDatabaseAdapter.java
com.bitflippersanonymous.flippy.db.FlippyDatabaseHelper.java
com.bitflippersanonymous.flippy.domain.EntryView.java
com.bitflippersanonymous.flippy.domain.PlsDbAdapter.java
com.bitflippersanonymous.flippy.domain.PlsEntry.java
com.bitflippersanonymous.flippy.domain.PodcastParser.java
com.bitflippersanonymous.flippy.domain.SimpleCursorLoader.java
com.bitflippersanonymous.flippy.service.FlippyPlayerService.java
com.bitflippersanonymous.flippy.util.ActivitySwipeDetector.java
com.bitflippersanonymous.flippy.util.Util.java