Skip to content
This repository has been archived by the owner on Jan 26, 2020. It is now read-only.

Commit

Permalink
OAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Jan 27, 2016
1 parent 0c01934 commit 968eae0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions app/src/main/java/rikka/searchbyimage/database/DatabaseHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package rikka.searchbyimage.database;

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

import rikka.searchbyimage.database.table.CustomEngineTable;

/**
* Created by Rikka on 2016/1/24.
*/
public class DatabaseHelper extends SQLiteOpenHelper{
public static final int DATABASE_VERSION = 2;
public static final String DATABASE_NAME = "search_engines.db";

private static DatabaseHelper instance;

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

public static synchronized DatabaseHelper instance(Context context) {
if (instance == null) {
instance = new DatabaseHelper(context);
}
return instance;
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CustomEngineTable.SQL_CREATE_ENTRIES);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion == 2) {
db.execSQL("ALTER TABLE " + CustomEngineTable.TABLE_NAME + " ADD " + CustomEngineTable.COLUMN_ENABLED + " integer NOT NULL DEFAULT(1)");
}
}
}

0 comments on commit 968eae0

Please sign in to comment.