-
public interface ICTPreferenceThe
<p> The implementation of this interface should encapsulate the underlying storage mechanism for shared preferences, allowing the CleverTap SDK to store and retrieve preference data in a specific manner. </p>ICTPreferenceinterface defines a set of methods for interacting with shared preferences to read and write various data types. It provides flexibility in handling preferences for different data types such as strings, booleans, integers, longs, floats, string sets, and maps.
-
-
Method Summary
Modifier and Type Method Description abstract StringreadString(String key, String default)Reads a string from the shared preferences. abstract BooleanreadBoolean(String key, Boolean default)Reads a boolean from the shared preferences. abstract IntegerreadInt(String key, Integer default)Reads an integer from the shared preferences. abstract LongreadLong(String key, Long default)Reads a long from the shared preferences. abstract FloatreadFloat(String key, Float default)Reads a float from the shared preferences. abstract Set<String>readStringSet(String key, Set<String> default)Reads a string set from the shared preferences. abstract Map<String, ?>readAll()Reads all key-value pairs from the shared preferences. abstract UnitwriteString(String key, String value)Writes a string to the shared preferences. abstract UnitwriteBoolean(String key, Boolean value)Writes a boolean to the shared preferences. abstract UnitwriteInt(String key, Integer value)Writes an integer to the shared preferences. abstract UnitwriteLong(String key, Long value)Writes a long to the shared preferences. abstract UnitwriteFloat(String key, Float value)Writes a float to the shared preferences. abstract UnitwriteStringSet(String key, Set<String> value)Writes a string set to the shared preferences. abstract UnitwriteMap(String key, Map<String, ?> value)Writes a map to the shared preferences. abstract UnitwriteStringImmediate(String key, String value)Writes a string to the shared preferences immediately (without applying changes asynchronously). abstract UnitwriteBooleanImmediate(String key, Boolean value)Writes a boolean to the shared preferences immediately (without applying changes asynchronously). abstract UnitwriteIntImmediate(String key, Integer value)Writes an integer to the shared preferences immediately (without applying changes asynchronously). abstract UnitwriteLongImmediate(String key, Long value)Writes a long to the shared preferences immediately (without applying changes asynchronously). abstract UnitwriteFloatImmediate(String key, Float value)Writes a float to the shared preferences immediately (without applying changes asynchronously). abstract UnitwriteStringSetImmediate(String key, Set<String> value)Writes a string set to the shared preferences immediately (without applying changes asynchronously). abstract UnitwriteMapImmediate(String key, Map<String, ?> value)Writes a map to the shared preferences immediately (without applying changes asynchronously). abstract BooleanisEmpty()Checks if the shared preferences are empty. abstract Integersize()Gets the size (number of key-value pairs) of the shared preferences. abstract Unitremove(String key)Removes a key and its associated value from the shared preferences. abstract UnitremoveImmediate(String key)Removes a key and its associated value from the shared preferences immediately (without applying changes asynchronously). abstract UnitchangePreferenceName(String prefName)Changes the name of the shared preferences. -
-
Method Detail
-
readString
abstract String readString(String key, String default)
Reads a string from the shared preferences.
- Parameters:
key- The key associated with the value.default- The default value to return if the key is not present.
-
readBoolean
abstract Boolean readBoolean(String key, Boolean default)
Reads a boolean from the shared preferences.
- Parameters:
key- The key associated with the value.default- The default value to return if the key is not present.
-
readInt
abstract Integer readInt(String key, Integer default)
Reads an integer from the shared preferences.
- Parameters:
key- The key associated with the value.default- The default value to return if the key is not present.
-
readLong
abstract Long readLong(String key, Long default)
Reads a long from the shared preferences.
- Parameters:
key- The key associated with the value.default- The default value to return if the key is not present.
-
readFloat
abstract Float readFloat(String key, Float default)
Reads a float from the shared preferences.
- Parameters:
key- The key associated with the value.default- The default value to return if the key is not present.
-
readStringSet
abstract Set<String> readStringSet(String key, Set<String> default)
Reads a string set from the shared preferences.
- Parameters:
key- The key associated with the value.default- The default value to return if the key is not present.
-
writeString
abstract Unit writeString(String key, String value)
Writes a string to the shared preferences.
- Parameters:
key- The key associated with the value.value- The string value to be stored.
-
writeBoolean
abstract Unit writeBoolean(String key, Boolean value)
Writes a boolean to the shared preferences.
- Parameters:
key- The key associated with the value.value- The boolean value to be stored.
-
writeInt
abstract Unit writeInt(String key, Integer value)
Writes an integer to the shared preferences.
- Parameters:
key- The key associated with the value.value- The integer value to be stored.
-
writeLong
abstract Unit writeLong(String key, Long value)
Writes a long to the shared preferences.
- Parameters:
key- The key associated with the value.value- The long value to be stored.
-
writeFloat
abstract Unit writeFloat(String key, Float value)
Writes a float to the shared preferences.
- Parameters:
key- The key associated with the value.value- The float value to be stored.
-
writeStringSet
abstract Unit writeStringSet(String key, Set<String> value)
Writes a string set to the shared preferences.
- Parameters:
key- The key associated with the value.value- The string set value to be stored.
-
writeMap
abstract Unit writeMap(String key, Map<String, ?> value)
Writes a map to the shared preferences.
- Parameters:
key- The key associated with the value.value- The map value to be stored.
-
writeStringImmediate
abstract Unit writeStringImmediate(String key, String value)
Writes a string to the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key associated with the value.value- The string value to be stored.
-
writeBooleanImmediate
abstract Unit writeBooleanImmediate(String key, Boolean value)
Writes a boolean to the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key associated with the value.value- The boolean value to be stored.
-
writeIntImmediate
abstract Unit writeIntImmediate(String key, Integer value)
Writes an integer to the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key associated with the value.value- The integer value to be stored.
-
writeLongImmediate
abstract Unit writeLongImmediate(String key, Long value)
Writes a long to the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key associated with the value.value- The long value to be stored.
-
writeFloatImmediate
abstract Unit writeFloatImmediate(String key, Float value)
Writes a float to the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key associated with the value.value- The float value to be stored.
-
writeStringSetImmediate
abstract Unit writeStringSetImmediate(String key, Set<String> value)
Writes a string set to the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key associated with the value.value- The string set value to be stored.
-
writeMapImmediate
abstract Unit writeMapImmediate(String key, Map<String, ?> value)
Writes a map to the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key associated with the value.value- The map value to be stored.
-
remove
abstract Unit remove(String key)
Removes a key and its associated value from the shared preferences.
- Parameters:
key- The key to be removed.
-
removeImmediate
abstract Unit removeImmediate(String key)
Removes a key and its associated value from the shared preferences immediately (without applying changes asynchronously).
- Parameters:
key- The key to be removed.
-
changePreferenceName
abstract Unit changePreferenceName(String prefName)
Changes the name of the shared preferences.
- Parameters:
prefName- The new name for the shared preferences.
-
-
-
-