package com.example.client;

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

public class SqlHelper extends SQLiteOpenHelper{
	
	//创建用户表
	String createUserTable = "create table user_info(_id int auto_increment,username char(20),"
		+ "password char(20),realname char(20),age char(20),sex char(20),primary key('_id'));";
	
	// 定义用户表插入语句
	String insertStr = "insert into user_info(_id,username,password,realname,age,sex) values(?,?,?,?,?,?)";

	public SqlHelper(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub\
		int _id = 0;
		// 创建用户表.
		db.execSQL(createUserTable);
		
		// 插入测试data
		String[] insertValue = { "0", "admin", "admin", "snow", "21", "男" };
		db.execSQL(insertStr, insertValue);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}
	
}
