Style-related changes
[zxing.git] / android / src / com / google / zxing / client / android / 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 com.google.zxing.client.android.history;
18
19 import android.database.sqlite.SQLiteOpenHelper;
20 import android.database.sqlite.SQLiteDatabase;
21 import android.content.Context;
22
23 /**
24  * @author Sean Owen
25  */
26 final class DBHelper extends SQLiteOpenHelper {
27
28   private static final int DB_VERSION = 2;
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
37   DBHelper(Context context) {
38     super(context, DB_NAME, null, DB_VERSION);
39   }
40
41   @Override
42   public void onCreate(SQLiteDatabase sqLiteDatabase) {
43     sqLiteDatabase.execSQL(
44             "CREATE TABLE " + TABLE_NAME + " (" +
45             ID_COL + " INTEGER PRIMARY KEY, " +
46             TEXT_COL + " TEXT, " +
47             FORMAT_COL + " TEXT, " +
48             DISPLAY_COL + " TEXT, " +
49             TIMESTAMP_COL + " INTEGER" +
50             ");");
51   }
52
53   @Override
54   public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
55     sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
56     onCreate(sqLiteDatabase);
57   }
58
59 }