Skip to content

Instantly share code, notes, and snippets.

@msdalp
Last active August 29, 2015 13:56
Show Gist options
  • Save msdalp/9295590 to your computer and use it in GitHub Desktop.
Save msdalp/9295590 to your computer and use it in GitHub Desktop.
public synchronized boolean setData(List<YourObject> _objects) {
final SQLiteDatabase db = this.getWritableDatabase();
boolean retval = false;
try {
db.delete(SQL.DATA, null, null);
for (YourObject object : _objects) {
ContentValues contentValues = new ContentValues();
contentValues.put("ID", object.id);
contentValues.put("NAME", object.name);
contentValues.put("ABBR", object.abbr);
contentValues.put("FOUND_YEAR", object.foundYear);
db.insert(SQL.DATA, null, contentValues);
}
retval = true;
} catch (Exception ex) {
Log.e(TAG, "setData exception", ex);
} finally {
db.close();
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment