]> nv-tegra.nvidia Code Review - android/platform/packages/apps/Tag.git/blob - src/com/android/apps/tag/provider/TagDBHelper.java
Re-implements MyTagList UI.
[android/platform/packages/apps/Tag.git] / src / com / android / apps / tag / provider / TagDBHelper.java
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
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.android.apps.tag.provider;
18
19 import com.android.apps.tag.provider.TagContract.NdefMessages;
20 import com.google.common.annotations.VisibleForTesting;
21
22 import android.content.Context;
23 import android.database.sqlite.SQLiteDatabase;
24 import android.database.sqlite.SQLiteOpenHelper;
25
26 /**
27  * Database utilities for the saved tags.
28  */
29 public class TagDBHelper extends SQLiteOpenHelper {
30
31     private static final String DATABASE_NAME = "tags.db";
32     private static final int DATABASE_VERSION = 15;
33
34     public static final String TABLE_NAME_NDEF_MESSAGES = "ndef_msgs";
35
36     TagDBHelper(Context context) {
37         this(context, DATABASE_NAME);
38     }
39
40     @VisibleForTesting
41     TagDBHelper(Context context, String dbFile) {
42         super(context, dbFile, null, DATABASE_VERSION);
43     }
44
45     @Override
46     public void onCreate(SQLiteDatabase db) {
47
48         db.execSQL("CREATE TABLE " + TABLE_NAME_NDEF_MESSAGES + " (" +
49                 NdefMessages._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
50                 NdefMessages.DATE + " INTEGER NOT NULL, " +
51                 NdefMessages.TITLE + " TEXT NOT NULL DEFAULT ''," +
52                 NdefMessages.BYTES + " BLOB NOT NULL, " +
53                 NdefMessages.STARRED + " INTEGER NOT NULL DEFAULT 0," +  // boolean
54                 NdefMessages.IS_MY_TAG + " INTEGER NOT NULL DEFAULT 0" + // boolean
55                 ");");
56     }
57
58     @Override
59     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
60         // Drop everything and recreate it for now
61         db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_NDEF_MESSAGES);
62         onCreate(db);
63     }
64 }