Android Open Source - ShowCast D B Helper






From Project

Back to project page ShowCast.

License

The source code is released under:

GNU General Public License

If you think the Android project ShowCast 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 prezcast.sgu.fr.showcast.db;
// w w  w. j a  v  a  2 s.  co m
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import prezcast.sgu.fr.showcast.db.setting.EnumSettingsType;
import prezcast.sgu.fr.showcast.db.setting.EnumSettingsZone;
import prezcast.sgu.fr.showcast.db.setting.Setting;
import prezcast.sgu.fr.showcast.db.setting.SettingsTable;

/**
 *
 */
public class DBHelper extends SQLiteOpenHelper {

    // TAg for logs.
    private static final String TAG = "ShowCast-DBHelper";

    // Database name
    private static final String DB_NAME = "ShowCast";
    // Database version
    private static final int DATABASE_VERSION = 1;

    /**
     * Constructor
     * @param context Application context.
     * @param factory Cursor factory
     */
    public DBHelper(Context context, SQLiteDatabase.CursorFactory factory) {
        super(context, DB_NAME, factory, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("DROP TABLE IF EXISTS " + SettingsTable.TABLE_NAME + ";");
        db.execSQL(SettingsTable.CREATE_TABLE);
        insertV1(db);
    }

    /**
     * Data for version 1.
     * @param db
     */
    private void insertV1(SQLiteDatabase db) {
        // Default directory for presentation
        Setting s = new Setting(EnumSettingsType.STRING, EnumSettingsZone.GENERAL,Setting.DEFAULT_DIRECTORY_KEY,Setting.DEFAULT_DIRECTORY_VALUE);
        try {
            SettingsTable.insert(s,db);
        } catch (DbException e) {
            Log.e(TAG,e.getMessage());
        }
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}




Java Source Code List

prezcast.sgu.fr.showcast.ApplicationTest.java
prezcast.sgu.fr.showcast.activity.MainActivity.java
prezcast.sgu.fr.showcast.activity.PresentationActivity.java
prezcast.sgu.fr.showcast.activity.SettingsActivity.java
prezcast.sgu.fr.showcast.async.SettingsAsync.java
prezcast.sgu.fr.showcast.db.DBHelper.java
prezcast.sgu.fr.showcast.db.DbException.java
prezcast.sgu.fr.showcast.db.setting.EnumSettingsType.java
prezcast.sgu.fr.showcast.db.setting.EnumSettingsZone.java
prezcast.sgu.fr.showcast.db.setting.Setting.java
prezcast.sgu.fr.showcast.db.setting.SettingsTable.java
prezcast.sgu.fr.showcast.presentation.PresentationContents.java
prezcast.sgu.fr.showcast.presentation.TvPresentation.java
prezcast.sgu.fr.showcast.roboguice.RoboActionBarActivity.java
prezcast.sgu.fr.showcast.view.SeparatedListAdapter.java
prezcast.sgu.fr.showcast.view.SettingDialog.java