mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-16 21:54:05 +02:00
catch sql exception on getScaleDataList method
This commit is contained in:
@@ -370,27 +370,31 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
public ArrayList<ScaleData> getScaleDataList(int userId) {
|
public ArrayList<ScaleData> getScaleDataList(int userId) {
|
||||||
ArrayList<ScaleData> scaleDataList = new ArrayList<ScaleData>();
|
ArrayList<ScaleData> scaleDataList = new ArrayList<ScaleData>();
|
||||||
|
|
||||||
String sortOrder = COLUMN_NAME_DATE_TIME + " DESC";
|
try {
|
||||||
|
String sortOrder = COLUMN_NAME_DATE_TIME + " DESC";
|
||||||
|
|
||||||
Cursor cursorScaleDB = dbRead.query(
|
Cursor cursorScaleDB = dbRead.query(
|
||||||
TABLE_NAME, // The table to query
|
TABLE_NAME, // The table to query
|
||||||
projection, // The columns to return
|
projection, // The columns to return
|
||||||
COLUMN_NAME_USER_ID + "=? AND " + COLUMN_NAME_ENABLE + "=1", // The columns for the WHERE clause
|
COLUMN_NAME_USER_ID + "=? AND " + COLUMN_NAME_ENABLE + "=1", // The columns for the WHERE clause
|
||||||
new String[]{Integer.toString(userId)}, // The values for the WHERE clause
|
new String[]{Integer.toString(userId)}, // The values for the WHERE clause
|
||||||
null, // don't group the rows
|
null, // don't group the rows
|
||||||
null, // don't filter by row groups
|
null, // don't filter by row groups
|
||||||
sortOrder // The sort order
|
sortOrder // The sort order
|
||||||
);
|
);
|
||||||
|
|
||||||
cursorScaleDB.moveToFirst();
|
cursorScaleDB.moveToFirst();
|
||||||
|
|
||||||
while (!cursorScaleDB.isAfterLast()) {
|
while (!cursorScaleDB.isAfterLast()) {
|
||||||
scaleDataList.add(readAtCursor(cursorScaleDB));
|
scaleDataList.add(readAtCursor(cursorScaleDB));
|
||||||
|
|
||||||
cursorScaleDB.moveToNext();
|
cursorScaleDB.moveToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorScaleDB.close();
|
cursorScaleDB.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
Log.e("ScaleDatabase", "SQL exception occured while getting scale data list: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
return scaleDataList;
|
return scaleDataList;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user