我有一个SQLite表,并希望暂时将其设置为默认值.我怎样才能做到这一点?

下面是我的DatabaseHelper类代码:

import android.content.Context;

import android.database.sqlite.SQLiteDatabase;

import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

private static final String DATABASE_NAME="iFall.db";

public static final String TIME="time";

//public static final String STATUS="status";

//public static final String MINES="loadmines";

//public static final String OPENTILE="openTile";

public DatabaseHelper(Context context)

{

super(context,DATABASE_NAME,null,1);

}

@Override

public void onCreate(SQLiteDatabase arg0) {

// TODO Auto-generated method stub

//CREATE TABLE minesweeper(_id INTEGER PRIMARY KEY AUTOINCREMENT,userId TEXT

arg0.execSQL("CREATE TABLE finalP(_id INTEGER PRIMARY KEY AUTOINCREMENT,time TEXT);");

}

@Override

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

// TODO Auto-generated method stub

db.execSQL("DROP TABLE IF EXISTS finalP");

onCreate(db);

}

}

我想为列时间分配一个默认值50.

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐