Created
March 1, 2014 19:25
-
-
Save msdalp/9295639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public synchronized boolean addData(List<YourObject> _objects) { | |
final SQLiteDatabase db = this.getWritableDatabase(); | |
boolean retval = false; | |
try { | |
for (YourObject object : _objects) { | |
ContentValues contentValues = new ContentValues(); | |
contentValues.put("ID", object.id); | |
contentValues.put("DATA_ID", object.dataId); | |
contentValues.put("VALUE", object.value); | |
db.insert("data",null,contentValues); | |
// db.insertWithOnConflict("data", null, contentValues, SQLiteDatabase.CONFLICT_REPLACE); | |
} | |
retval = true; | |
} catch (Exception ex) { | |
Log.e(TAG, "addData exception", ex); | |
} finally { | |
db.close(); | |
} | |
return retval; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment