Created
December 9, 2014 14:46
-
-
Save masazdream/1b75712232fe53aa9c4d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public class GuiterOpenHelper extends SQLiteOpenHelper { | |
| // データーベースのバージョン | |
| // データベーススキーマを変える場合は、バージョンを上げること | |
| private static final int DATABASE_VERSION = 1; | |
| public static final String DATABASE_NAME = "Sample.db"; | |
| private static final String BOOK_TABLE_CREATE = | |
| "CREATE TABLE " + Book.BOOK_TABLE_NAME + " (" + | |
| Guiter._ID + " INTEGER PRIMARY KEY," + | |
| Guiter.COLUMN_NAME_GUITER_NAME + " TEXT NOT NULL, " + | |
| Guiter.COLUMN_NAME_GUITER_MAKER + " TEXT, " + | |
| Guiter.COLUMN_NAME_GUITER_PRICE + " TEXT);"; | |
| private static final String GUITER_TABLE_DELETE = | |
| "DROP TABLE IF EXISTS " + Guiter.GUITER_TABLE_NAME; | |
| public GuiterOpenHelper(Context context) { | |
| // データベース名、バージョンを指定する | |
| super(context, DATABASE_NAME, null, DATABASE_VERSION); | |
| } | |
| @Override | |
| public void onCreate(SQLiteDatabase db) { | |
| // テーブル作成 | |
| db.execSQL(GUITER_TABLE_CREATE); | |
| } | |
| @Override | |
| public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |
| // ここでアップデート条件を判定する | |
| db.execSQL(GUITER_TABLE_DELETE); | |
| onCreate(db); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment