package com.luofei.cp;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class MyDataBase extends SQLiteOpenHelper {
//构造函数
public MyDataBase(Context context) {
super(context, Utils.DBNAME, null, Utils.VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("create table "+Utils.TNAME+"(" +
Utils.TID+" integer primary key autoincrement not null,"+
Utils.EMAIL+" text not null," +
Utils.USERNAME+" text not null," +
Utils.DATE+" interger not null,"+
Utils.SEX+" text not null);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
public void add(String email,String username,String date,String sex){
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Utils.EMAIL, email);
values.put(Utils.USERNAME, username);
values.put(Utils.DATE, date);
values.put(Utils.SEX, sex);
db.insert(Utils.TNAME,"",values);
}
}