package com.app.phr;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DatabaseHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "OwnRecordDB";
private static final int DB_VERSION = 1;
private static final String DB_CREATE1 = "" +
"CREATE TABLE information (" +
"id INTEGER PRIMARY KEY, " +
"name TEXT NOT NULL, " +
"address TEXT NOT NULL, " +
"telephone TEXT NOT NULL, " +
"birthday TEXT NOT NULL, " +
"sex TEXT NOT NULL, " +
"age TEXT NOT NULL, " +
"weight TEXT NOT NULL, " +
"height TEXT NOT NULL, " +
"congen TEXT (100));";
private static final String DB_CREATE2 = "" +
"CREATE TABLE gallery (" +
"id INTEGER PRIMARY KEY, " +
"photoname TEXT (500), " +
"path TEXT (500));";
public DatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION );
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DB_CREATE1);
db.execSQL(DB_CREATE2);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(DatabaseHelper.class.getName(),
"Upgread database version from version" + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS information");
db.execSQL("DROP TABLE IF EXISTS gallery");
onCreate(db);
}
}