我的Android应用程序从服务器获取数据然后将其存储在SQL本地,当我第一次在移动设备上安装应用程序创建SQL数据库然后它检查当前数据和从服务器获取的数据然后它比较数据是否匹配或不,如果没有,那么首先它调用删除方法
public void deleteUfoneData() {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM " + ufoneEntry.TABLE_NAME);
}
然后它调用insert方法,因为数据库是空的delete方法执行没有问题但是当我对服务器数据进行更改然后再次启动应用程序然后它在删除方法上崩溃,我出错了?
public boolean insertWaridData(String name, String price, String vol, String val, String sub, String unsub, String bal) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(waridEntry.COLUMN_PACKAGE_NAME, name);
contentValues.put(waridEntry.COLUMN_PACKAGE_PRICE, price);
contentValues.put(waridEntry.COLUMN_PACKAGE_VOL, vol);
contentValues.put(waridEntry.COLUMN_PACKAGE_VAL, val);
contentValues.put(waridEntry.COLUMN_PACKAGE_SUB, sub);
contentValues.put(waridEntry.COLUMN_PACKAGE_UNSUB, unsub);
contentValues.put(waridEntry.COLUMN_PACKAGE_BAL, bal);
long result = db.insert(waridEntry.TABLE_NAME, null, contentValues);
if (result == -1) {
return false;
} else {
return true;
}
}