Package com.zendesk.sdk.storage
Interface SdkSettingsStorage
-
public interface SdkSettingsStorage
This class contains methods for interacting with the storedSdkSettings
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description boolean
areSettingsUpToDate(long duration, java.util.concurrent.TimeUnit timeUnit)
Determine if the stored settings older than the provided amount of time.void
deleteStoredSettings()
Deletes any storedMobileSettings
that may be present in theSharedPreferences
.SafeMobileSettings
getStoredSettings()
boolean
hasStoredSdkSettings()
This method can check to see if there are any storedMobileSettings
in theSharedPreferences
void
setStoredSettings(SafeMobileSettings mobileSettings)
Saves the suppliedMobileSettings
toSharedPreferences
.
-
-
-
Method Detail
-
hasStoredSdkSettings
boolean hasStoredSdkSettings()
This method can check to see if there are any storedMobileSettings
in theSharedPreferences
- Returns:
- true if the storage has
MobileSettings
stored
-
areSettingsUpToDate
boolean areSettingsUpToDate(long duration, java.util.concurrent.TimeUnit timeUnit)
Determine if the stored settings older than the provided amount of time.- Parameters:
duration
- the time duration in the giventimeUnit
timeUnit
- the unit of theduration
argument- Returns:
true
if the settings are loaded in the provided time range,false
if they are outdated.
-
getStoredSettings
SafeMobileSettings getStoredSettings()
Gets the storedMobileSettings
from theSharedPreferences
, wrapped in aSafeMobileSettings
.If the
MobileSettings
were found but do not deserialise correctly then the saved settings will be removed usingSdkSettingsStorage.deleteStoredSettings()
as this is probably due to irrecoverable differences in the stored model and a new one.- Returns:
- The
SafeMobileSettings
which wraps theMobileSettings
if they are available in storage or null if there were no saved settings or there was a problem with deserialisation. TheSafeMobileSettings
will handle the case that theMobileSettings
, or any of its properties, are null.
-
setStoredSettings
void setStoredSettings(SafeMobileSettings mobileSettings)
Saves the suppliedMobileSettings
toSharedPreferences
.If the supplied
MobileSettings
is null then this will not save the settings toSharedPreferences
. If the intention is to delete them then please useSdkSettingsStorage.deleteStoredSettings()
- Parameters:
mobileSettings
- TheSafeMobileSettings
to save.
-
deleteStoredSettings
void deleteStoredSettings()
Deletes any storedMobileSettings
that may be present in theSharedPreferences
.Note that this clears all keys that have been created by this class. Please be wary of this if you are using this class to store more than just the JSON representation of the
MobileSettings
using the MOBILE_SETTINGS_KEY
-
-