Android Open Source - android-sqlite-kvs D B Helper






From Project

Back to project page android-sqlite-kvs.

License

The source code is released under:

Apache License

If you think the Android project android-sqlite-kvs 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 jp.fkmsoft.libs.sqlitekvs.impl;
/*  w  ww.  j a  v a  2  s  .  co m*/
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

/**
 * Helper class for {@link android.database.sqlite.SQLiteOpenHelper}
 */
class DBHelper extends SQLiteOpenHelper {

    private static final int DB_VERSION = 1;

    static final String TABLE_NAME = "kvs";

    interface Columns extends BaseColumns {
        static final String ID = "id";
        static final String VALUE = "value";
    }

    private static final String SQL_CREATE =
            "create table " + TABLE_NAME + "(" +
            Columns._ID + " integer primary key autoincrement," +
            Columns.ID + " text," +
            Columns.VALUE + " blob)";
    private static final String SQL_INDEX =
            "create unique index idx_" + TABLE_NAME +
            " on " + TABLE_NAME +
            "(" + Columns.ID + ")";

    DBHelper(Context context, String name) {
        super(context, name + ".db", null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SQL_CREATE);
        db.execSQL(SQL_INDEX);
    }

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

    }
}




Java Source Code List

jp.fkmsoft.libs.sqlitekvs.KVSException.java
jp.fkmsoft.libs.sqlitekvs.KVS.java
jp.fkmsoft.libs.sqlitekvs.impl.DBHelper.java
jp.fkmsoft.libs.sqlitekvs.impl.KVSImpl.java
jp.fkmsoft.libs.sqlitekvs.json.JsonKVS.java
jp.fkmsoft.libs.sqlitekvs.json.TestJsonKVS.java
jp.fkmsoft.libs.sqlitekvs.util.DBUtils.java