Package com.iplateia.sorisdk
Class HelperKt
-
- All Implemented Interfaces:
public final class HelperKt
-
-
Method Summary
Modifier and Type Method Description final static UnitsetPreference(Context context, String key, String value)Save a string preference in shared preferences. final static UnitsetPreference(Context context, String key, Object value)Save an object preference in shared preferences. final static StringgetPreference(Context context, String key)Retrieve a string preference from shared preferences. final static StringgetPreference(Context context, String key, String defaultValue)Retrieve a string preference from shared preferences with a default value. final static StringgetDeviceId(Context context)Create or retrive the device ID from shared preferences. final static UnitsetDeviceId(Context context, String deviceId)Set the device ID manually in shared preferences. -
-
Method Detail
-
setPreference
final static Unit setPreference(Context context, String key, String value)
Save a string preference in shared preferences.
- Parameters:
context- The context from which to access shared preferenceskey- The key for the preferencevalue- The value to set
-
setPreference
final static Unit setPreference(Context context, String key, Object value)
Save an object preference in shared preferences. The value should be serializable using Kotlin serialization.
- Parameters:
context- The context from which to access shared preferenceskey- The key for the preference
-
getPreference
final static String getPreference(Context context, String key)
Retrieve a string preference from shared preferences.
- Parameters:
context- The context from which to access shared preferenceskey- The key for the preference- Returns:
The value of the preference, or null if not found
-
getPreference
final static String getPreference(Context context, String key, String defaultValue)
Retrieve a string preference from shared preferences with a default value.
- Parameters:
context- The context from which to access shared preferenceskey- The key for the preferencedefaultValue- The default value to return if the preference is not found- Returns:
The value of the preference, or the default value if not found
-
getDeviceId
final static String getDeviceId(Context context)
Create or retrive the device ID from shared preferences. If it doesn't exist, it generates a new UUID and saves it.
- Parameters:
context- The context from which to access shared preferences- Returns:
The device ID as a string
-
setDeviceId
final static Unit setDeviceId(Context context, String deviceId)
Set the device ID manually in shared preferences.
- Parameters:
context- The context from which to access shared preferencesdeviceId- The device ID to set
-
-
-
-