Class DataStorage
java.lang.Object
de.kaffeemitkoffein.tinyweatherforecastgermany.DataStorage
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final longstatic final intstatic final longstatic final intstatic final longstatic final intstatic final longstatic final intstatic final intstatic final intstatic final intstatic final intstatic final Stringstatic final intstatic final intstatic final intstatic final longstatic final intstatic final intstatic final intstatic final longstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear(Context context) static byte[]getBlob(Context context, int id, byte[] defaultValue) static booleangetBoolean(Context context, int id, boolean defaultValue) Retrieves a boolean value from storage.static floatgetFloat(Context context, int id, float defaultValue) static intgetInt(Context context, int id, int defaultValue) static longgetLong(Context context, int id, long defaultValue) static Weather.WeatherLocationgetSetStationLocation(Context context) Retrieves the currently selected weather station location from storage.static Stringstatic voidprintPackages(Context context, ArrayList<DataPackage> dataPackages) static ArrayList<DataPackage> readAllPackages(Context context) static DataPackagereadDataPackage(Context context, int id) Retrieves a single data package from storage by its ID.static voidsetBlob(Context context, int id, byte[] value) static voidsetBoolean(Context context, int id, boolean value) static voidsetFloat(Context context, int id, float value) static voidsetInt(Context context, int id, int value) static voidsetLong(Context context, int id, long value) static voidsetStation(Context context, Weather.WeatherLocation weatherLocation) Stores the currently selected weather station location in persistent storage.static void
-
Field Details
-
DATASTORAGE_STATION
public static final int DATASTORAGE_STATION- See Also:
-
DATASTORAGE_TEST
public static final int DATASTORAGE_TEST- See Also:
-
DATASTORAGE_POLLENREGION_ID
public static final int DATASTORAGE_POLLENREGION_ID- See Also:
-
DATASTORAGE_POLLENPARTREGION_ID
public static final int DATASTORAGE_POLLENPARTREGION_ID- See Also:
-
DATASTORAGE_POLLENREGION_DESCRIPTION
public static final int DATASTORAGE_POLLENREGION_DESCRIPTION- See Also:
-
DATASTORAGE_LASTGPSFIX
public static final int DATASTORAGE_LASTGPSFIX- See Also:
-
DATASTORAGE_NOTIFICATION_IDENTIFIER
public static final int DATASTORAGE_NOTIFICATION_IDENTIFIER- See Also:
-
DATASTORAGE_LAST_NOTIFICATIONS_UPDATE_TIME
public static final int DATASTORAGE_LAST_NOTIFICATIONS_UPDATE_TIME- See Also:
-
DATASTORAGE_NC_CHANNEL_DETAIL
public static final int DATASTORAGE_NC_CHANNEL_DETAIL- See Also:
-
DATASTORAGE_WEATHERUPDATEDFLAG
public static final int DATASTORAGE_WEATHERUPDATEDFLAG- See Also:
-
DATASTORAGE_RADAR_LASTDATAPOLL
public static final int DATASTORAGE_RADAR_LASTDATAPOLL- See Also:
-
DATASTORAGE_VIEWS_LAST_UPDATE_TIME
public static final int DATASTORAGE_VIEWS_LAST_UPDATE_TIME- See Also:
-
DATASTORAGE_GADGETBRIDGE_LASTUPDATE
public static final int DATASTORAGE_GADGETBRIDGE_LASTUPDATE- See Also:
-
DATASTORAGE_POLLENREGION_ID_DEFAULT
public static final int DATASTORAGE_POLLENREGION_ID_DEFAULT- See Also:
-
DATASTORAGE_POLLENPARTREGION_ID_DEFAULT
public static final int DATASTORAGE_POLLENPARTREGION_ID_DEFAULT- See Also:
-
DATASTORAGE_POLLENREGION_DESCRIPTION_DEFAULT
- See Also:
-
DATASTORAGE_LASTGPSFIX_DEFAULT
public static final long DATASTORAGE_LASTGPSFIX_DEFAULT- See Also:
-
DATASTORAGE_NOTIFICATION_IDENTIFIER_DEFAULT
public static final int DATASTORAGE_NOTIFICATION_IDENTIFIER_DEFAULT- See Also:
-
DATASTORAGE_LAST_NOTIFICATIONS_UPDATE_TIME_DEFAULT
public static final long DATASTORAGE_LAST_NOTIFICATIONS_UPDATE_TIME_DEFAULT- See Also:
-
DATASTORAGE_NC_CHANNEL_DETAIL_DEFAULT
public static final long DATASTORAGE_NC_CHANNEL_DETAIL_DEFAULT- See Also:
-
DATASTORAGE_WEATHERUPDATEDFLAG_DEFAULT
public static final int DATASTORAGE_WEATHERUPDATEDFLAG_DEFAULT- See Also:
-
DATASTORAGE_RADAR_LASTDATAPOLL_DEFAULT
public static final long DATASTORAGE_RADAR_LASTDATAPOLL_DEFAULT- See Also:
-
DATASTORAGE_VIEWS_LAST_UPDATE_TIME_DEFAULT
public static final long DATASTORAGE_VIEWS_LAST_UPDATE_TIME_DEFAULT- See Also:
-
DATASTORAGE_GADGETBRIDGE_LASTUPDATE_DEFAULT
public static final long DATASTORAGE_GADGETBRIDGE_LASTUPDATE_DEFAULT- See Also:
-
-
Constructor Details
-
DataStorage
public DataStorage()
-
-
Method Details
-
readAllPackages
-
printPackages
-
readDataPackage
Retrieves a single data package from storage by its ID. This is the core read method used by all typed getter methods (getInt, getLong, etc.). The method queries the database using the ContentResolver, retrieves the cursor, and converts the first matching row into a DataPackage object.- Parameters:
context- the application contextid- the storage ID constant identifying which data to retrieve- Returns:
- the DataPackage containing the stored value, or null if not found
-
clear
public static void clear(Context context) -
setBlob
public static void setBlob(Context context, int id, byte[] value) -
getBlob
public static byte[] getBlob(Context context, int id, byte[] defaultValue) -
setFloat
public static void setFloat(Context context, int id, float value) -
getFloat
public static float getFloat(Context context, int id, float defaultValue) -
setInt
public static void setInt(Context context, int id, int value) -
getInt
public static int getInt(Context context, int id, int defaultValue) -
setLong
public static void setLong(Context context, int id, long value) -
getLong
public static long getLong(Context context, int id, long defaultValue) -
setString
-
getString
-
setBoolean
public static void setBoolean(Context context, int id, boolean value) -
getBoolean
public static boolean getBoolean(Context context, int id, boolean defaultValue) Retrieves a boolean value from storage. Note: Boolean values are stored as long (0 for false, non-zero for true).- Parameters:
context- the application contextid- the storage ID constantdefaultValue- the default value to return if no data exists- Returns:
- the stored boolean value, or defaultValue if not found
-
setStation
Stores the currently selected weather station location in persistent storage. The location is serialized to a string format before storage.- Parameters:
context- the application contextweatherLocation- the weather station location to store
-
getSetStationLocation
Retrieves the currently selected weather station location from storage. If no station has been set, this method initializes storage with the default station and returns that default location. This is a "get-or-set" pattern: it guarantees a valid weather location is always returned by creating and storing a default if none exists.- Parameters:
context- the application context- Returns:
- the stored weather location, or the default location if none was previously set
-