android中的SQLite在创建数据库,并且创建表后,如何给表增加列数 25
publicvoidonCreate(SQLiteDatabasedb){db.execSQL("createtabledownload_info(_idintegerP...
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table download_info(_id integer PRIMARY KEY AUTOINCREMENT, thread_id integer, "
+ "start_pos integer, end_pos integer, compelete_size integer,url char)");
}
//加字段
private void upgradeDatabaseToVersion1(SQLiteDatabase db) {
db.execSQL("ALTER TABLE download_info ADD COLUMN state integer");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch (oldVersion) {
case 0:
if (newVersion <= 1) {
return;
}
db.beginTransaction();
try {
upgradeDatabaseToVersion1(db);
db.setTransactionSuccessful();
} catch (Throwable ex) {
break;
} finally {
db.endTransaction();
}
return;
}
onCreate(db);
}
state没有添加成功,请帮帮我 展开
db.execSQL("create table download_info(_id integer PRIMARY KEY AUTOINCREMENT, thread_id integer, "
+ "start_pos integer, end_pos integer, compelete_size integer,url char)");
}
//加字段
private void upgradeDatabaseToVersion1(SQLiteDatabase db) {
db.execSQL("ALTER TABLE download_info ADD COLUMN state integer");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch (oldVersion) {
case 0:
if (newVersion <= 1) {
return;
}
db.beginTransaction();
try {
upgradeDatabaseToVersion1(db);
db.setTransactionSuccessful();
} catch (Throwable ex) {
break;
} finally {
db.endTransaction();
}
return;
}
onCreate(db);
}
state没有添加成功,请帮帮我 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询