This repository has been archived by the owner on Jan 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RikkaW
committed
Jan 27, 2016
1 parent
0c01934
commit 968eae0
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/src/main/java/rikka/searchbyimage/database/DatabaseHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)"); | ||
} | ||
} | ||
} |