package jp.gihyo.mitoma.android.p014gdpmanagement;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class CountryOpenHelper extends SQLiteOpenHelper {
    private static final String DB_NAME = "countryDB.db";
    private static final int DB_VERSION = 1;

    public CountryOpenHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }
    public void onCreate(SQLiteDatabase db) {
        // 初回作成時に呼ばれる
        String sql = "CREATE TABLE country(" +
                "country_no INTEGER PRIMARY KEY," +
                " country_name TEXT NOT NULL," +
                " gdp REAL," +
                "population REAL)";
        db.execSQL(sql);
    }
    public void onUpgrade(
            SQLiteDatabase db, int oldVersion, int newVersion) {
        // バージョン変更時の処理
        String sql = "DROP TABLE IF EXISTS country";
        db.execSQL(sql);
        onCreate(db);
    }






}
