2 * Copyright (C) 2009 ZXing authors
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package cz.cvut.fel.dce.barcodescanner.history;
19 import android.content.Context;
20 import android.database.sqlite.SQLiteDatabase;
21 import android.database.sqlite.SQLiteOpenHelper;
26 final class DBHelper extends SQLiteOpenHelper {
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";
38 DBHelper(Context context) {
39 super(context, DB_NAME, null, DB_VERSION);
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);");
55 public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
56 sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
57 onCreate(sqLiteDatabase);