package com.jarrettw.jarrettweather.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

//×÷ÓÃ£º½¨Á¢Êý¾Ý¿â±í
public class JarrettWeatherOpenHelper extends SQLiteOpenHelper{
	
	//Ê¡·Ý±í
	private static final String CREATE_PROVINCE = "create table Province("
			+ "id integer primary key autoincrement, "
			+ "province_name text)";
	
	//³ÇÊÐ±í
	private static final String CREATE_CITY = "create table City("
			+ "id integer primary key autoincrement, "
			+ "city_name text, "
			+ "province_id integer)";
	
	//ÏØ±í
	private static final String CREATE_DISTRICT = "create table District("
			+ "id integer primary key autoincrement, "
			+ "district_name text, "
			+ "city_id integer)";
	
	//¹¹Ôì·½·¨,±ØÐëÊµÏÖ»ùÀà¹¹Ôì·½·¨
	public JarrettWeatherOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
		super(context, name, factory, version);
	}
	
	//¸²Ð´
	@Override
	public void onCreate(SQLiteDatabase db){
		//´´½¨ÒÔÉÏÈý¸ö±í
		db.execSQL(CREATE_PROVINCE);
		db.execSQL(CREATE_CITY);
		db.execSQL(CREATE_DISTRICT);
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		
	}
	
}
