my android app fetch data from server then store it locally in SQL, when i install app first time on mobile it creates SQL database then it checks the current data and the data fetched from server then it compares if the data is matched or not, if not then first it call delete method
public void deleteUfoneData() {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM " + ufoneEntry.TABLE_NAME);
}
then it calls insert method, since the database is empty delete method executes without problem but when i make changes on server data then launch app again then it crashes on delete method, where i went wrong ?
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;
}
}