mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-13 12:14:19 +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");
|
Log.e("OpenScale", "Can't parse date time string while adding to the database");
|
||||||
}
|
}
|
||||||
|
|
||||||
scaleDB.insertEntry(scaleData);
|
if (scaleDB.insertEntry(scaleData)) {
|
||||||
|
updateScaleData();
|
||||||
updateScaleData();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScaleData(long id, String date_time, float weight, float fat, float water, float muscle, float waist, float hip, String comment) {
|
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 + "=?",
|
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);
|
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) {
|
if (cursorScaleDB.getCount() > 0) {
|
||||||
// we don't want double entries
|
cursorScaleDB.close();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
@@ -135,6 +136,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
Log.e("ScaleDatabase", "An error occured while inserting a new entry into the scale database: " + e.toString());
|
Log.e("ScaleDatabase", "An error occured while inserting a new entry into the scale database: " + e.toString());
|
||||||
|
cursorScaleDB.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user