]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - BarCodeScanner/mobile/src/main/java/cz/cvut/fel/dce/barcodescanner/history/DBHelper.java
Initial commit
[hornmich/skoda-qr-demo.git] / BarCodeScanner / mobile / src / main / java / cz / cvut / fel / dce / barcodescanner / history / DBHelper.java
1 /*
2  * Copyright (C) 2009 ZXing authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package cz.cvut.fel.dce.barcodescanner.history;
18
19 import android.content.Context;
20 import android.database.sqlite.SQLiteDatabase;
21 import android.database.sqlite.SQLiteOpenHelper;
22
23 /**
24  * @author Sean Owen
25  */
26 final class DBHelper extends SQLiteOpenHelper {
27
28   private static final int DB_VERSION = 5;
29   private static final String DB_NAME = "barcode_scanner_history.db";
30   static final String TABLE_NAME = "history";
31   static final String ID_COL = "id";
32   static final String TEXT_COL = "text";
33   static final String FORMAT_COL = "format";
34   static final String DISPLAY_COL = "display";
35   static final String TIMESTAMP_COL = "timestamp";
36   static final String DETAILS_COL = "details";
37
38   DBHelper(Context context) {
39     super(context, DB_NAME, null, DB_VERSION);
40   }
41
42   @Override
43   public void onCreate(SQLiteDatabase sqLiteDatabase) {
44     sqLiteDatabase.execSQL(
45             "CREATE TABLE " + TABLE_NAME + " (" +
46             ID_COL + " INTEGER PRIMARY KEY, " +
47             TEXT_COL + " TEXT, " +
48             FORMAT_COL + " TEXT, " +
49             DISPLAY_COL + " TEXT, " +
50             TIMESTAMP_COL + " INTEGER, " +
51             DETAILS_COL + " TEXT);");
52   }
53
54   @Override
55   public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
56     sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
57     onCreate(sqLiteDatabase);
58   }
59
60 }