mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-12 19:54:29 +02:00
update only scale data only if its not a duplicate entry
This commit is contained in:
@@ -177,9 +177,9 @@ public class OpenScale {
|
||||
Log.e("OpenScale", "Can't parse date time string while adding to the database");
|
||||
}
|
||||
|
||||
scaleDB.insertEntry(scaleData);
|
||||
|
||||
updateScaleData();
|
||||
if (scaleDB.insertEntry(scaleData)) {
|
||||
updateScaleData();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateScaleData(long id, String date_time, float weight, float fat, float water, float muscle, float waist, float hip, String comment) {
|
||||
|
@@ -113,8 +113,9 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
||||
Cursor cursorScaleDB = db.query(TABLE_NAME, new String[] {COLUMN_NAME_DATE_TIME}, COLUMN_NAME_DATE_TIME + "=? AND " + COLUMN_NAME_USER_ID + "=?",
|
||||
new String[] {formatDateTime.format(scaleData.date_time), Integer.toString(scaleData.user_id)}, null, null, null);
|
||||
|
||||
// we don't want double entries
|
||||
if (cursorScaleDB.getCount() > 0) {
|
||||
// we don't want double entries
|
||||
cursorScaleDB.close();
|
||||
return false;
|
||||
} else {
|
||||
ContentValues values = new ContentValues();
|
||||
@@ -135,6 +136,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
||||
catch (SQLException e)
|
||||
{
|
||||
Log.e("ScaleDatabase", "An error occured while inserting a new entry into the scale database: " + e.toString());
|
||||
cursorScaleDB.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user