android 데이터베이스 만들기

974 단어
public class MySQLLiteHelper extends SQLiteOpenHelper
{


/**
*      :           
* param1: context      
* param2: name       
* param3: factory     Cursor 
* parma4: varsion                 0  
* @param context
*/
public MySQLLiteHelper(Context context, String name, CursorFactory factory,
int version) {
super(context, "test.db", null, 2);
}


/**
*        
*/
@Override
public void onCreate(SQLiteDatabase db) {
String sql = "create table person (_id integer primary key, name varchar(20), age integer);";

db.execSQL(sql);//          
}


//       
//        ,      
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.d("============", oldVersion + "  : " + newVersion);
if(oldVersion == 1)
{
String sql = "alter table person add balance integer;";
db.execSQL(sql);
}
}

//            
@Override
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
}

좋은 웹페이지 즐겨찾기