
Facilitates local data storage, retrieval, and removal across platforms using native mechanisms. Supports various data types, including custom serializable objects through kotlinx-serialization integration.
v1.1.1
Kotlin Multiplatform Pref(erence)s system allows you to locally store, retrieve, and remove data on each platform, leveraging the native APIs provided by each platform:
Android target leverages the SharedPreferences APIsiOS and macOS targets leverage the UserDefaults APIsJVM target leverages the Preferences APIsWeb target leverages the LocalStorage APIsdependencies {
implementation 'io.github.n7ghtm4r3:kmprefs:1.1.1'
}dependencies {
implementation("io.github.n7ghtm4r3:kmprefs:1.1.1")
}[versions]
kmprefs = "1.1.1"
[libraries]
kmprefs = { module = "io.github.n7ghtm4r3:kmprefs", version.ref = "kmprefs" }dependencies {
implementation(libs.kmprefs)
}| Type | Description |
|---|---|
Boolean |
Boolean type (true/false) |
BooleanArray |
Array of Boolean
|
Byte |
8-bit signed integer |
ByteArray |
Array of Byte
|
UByte |
8-bit unsigned integer |
UByteArray |
Array of UByte
|
Short |
16-bit signed integer |
ShortArray |
Array of Short
|
UShort |
16-bit unsigned integer |
UShortArray |
Array of UShort
|
Int |
32-bit signed integer |
IntArray |
Array of Int
|
UInt |
32-bit unsigned integer |
UIntArray |
Array of UInt
|
Float |
32-bit floating-point number |
FloatArray |
Array of Float
|
Double |
64-bit floating-point number |
DoubleArray |
Array of Double
|
Long |
64-bit signed integer |
LongArray |
Array of Long
|
ULong |
64-bit unsigned integer |
ULongArray |
Array of ULong
|
String |
String of characters |
Serializable |
Custom serializable objects |
Enum |
Entry of any Enum
|
val kmPrefs = KMPrefs("your_storage_path") // create an instance
kmPrefs.store(
key = "constant", // the key of the value to store
value = 3.14159265359 // a primitive value to store
)Under the hood KMPrefs works with the kotlinx-serialization library
so it is required to import both the library and the plugin to correctly store and retrieve custom objects
@Serializable // required
data class Car(
val plate: String,
val hp: Int
)val kmPrefs = KMPrefs("your_storage_path") // create an instance
// create the instance to store
val carToStore = Car(
plate = "AA000AA",
hp = 450
)
// store the created instance
kmPrefs.store(
key = "your_key",
value = carToStore
) To safeguard sensitive data (such as token, ids, etc...) you can do as follows to encrypt values before their storage:
val kmPrefs = KMPrefs("your_storage_path") // create an instance
kmPrefs.store(
key = "constant", // the key of the value to store
value = 3.14159265359, // a primitive value to store,
isSensitive = true // the value will be stored encrypted
)val constant: Double? = kmPrefs.retrieve(
key = "constant",
defValue = 1.6180339887 // a default value to use whether the searched one is not stored yet
)// retrieve the car
val carToStore: Car = kmPrefs.retrieve(
key = "your_key",
deserializer = ,// custom deserializer to use during the retrieve whether the type is not explicit
defValue = Car(
plate = "not_found",
hp = 0
) // a default value to use whether the searched one is not stored yet
)To correctly retrieve and use a sensitive data previously stored you can follow the below guide
If your project does not target the Web platform you can normally use the retrieve method to retrieve the sensitive
data and then using it:
val constant: Double? = kmPrefs.retrieve(
key = "constant",
defValue = 1.6180339887, // a default value to use whether the searched one is not stored yet
isSensitive = true // the value will be retrieved decrypted
)Otherwise, if your project targets the Web platform you have to use the consumeRetrieval method to retrieve the
sensitive data and then consuming it:
kmPrefs.consumeRetrieval<Double>(
key = "constant",
defValue = 1.6180339887, // a default value to use whether the searched one is not stored yet
isSensitive = true, // the value will be retrieved decrypted
consume = { retrievedValue ->
println(retrievedValue) // decrypted value locally retrieved
}
)With the removeValue method you can remove a preference previously stored, it has no effect if the specified key is not
used by any preference
kmPrefs.removeValue(
key = "constant"
) With the clearAll method you can remove all the preferences currently stored by the library:
kmPrefs.clearAll() With the hasKey method you can check whether a key has been previously used to store a preference or whether a
specific preference is currently stored:
kmPrefs.hasKey(
key = "your_key"
)Check out the library documentation here!
If you need help using the library or encounter any problems or bugs, please contact us via the following links:
Thank you for your help!
If you want support project and developer
| Crypto | Address | Network |
|---|---|---|
| 3H3jyCzcRmnxroHthuXh22GXXSmizin2yp | Bitcoin | |
| 0x1b45bc41efeb3ed655b078f95086f25fc83345c4 | Ethereum | |
| AtPjUnxYFHw3a6Si9HinQtyPTqsdbfdKX3dJ1xiDjbrL | Solana |
If you want support project and developer with PayPal
Copyright © 2026 Tecknobit
v1.1.1
Kotlin Multiplatform Pref(erence)s system allows you to locally store, retrieve, and remove data on each platform, leveraging the native APIs provided by each platform:
Android target leverages the SharedPreferences APIsiOS and macOS targets leverage the UserDefaults APIsJVM target leverages the Preferences APIsWeb target leverages the LocalStorage APIsdependencies {
implementation 'io.github.n7ghtm4r3:kmprefs:1.1.1'
}dependencies {
implementation("io.github.n7ghtm4r3:kmprefs:1.1.1")
}[versions]
kmprefs = "1.1.1"
[libraries]
kmprefs = { module = "io.github.n7ghtm4r3:kmprefs", version.ref = "kmprefs" }dependencies {
implementation(libs.kmprefs)
}| Type | Description |
|---|---|
Boolean |
Boolean type (true/false) |
BooleanArray |
Array of Boolean
|
Byte |
8-bit signed integer |
ByteArray |
Array of Byte
|
UByte |
8-bit unsigned integer |
UByteArray |
Array of UByte
|
Short |
16-bit signed integer |
ShortArray |
Array of Short
|
UShort |
16-bit unsigned integer |
UShortArray |
Array of UShort
|
Int |
32-bit signed integer |
IntArray |
Array of Int
|
UInt |
32-bit unsigned integer |
UIntArray |
Array of UInt
|
Float |
32-bit floating-point number |
FloatArray |
Array of Float
|
Double |
64-bit floating-point number |
DoubleArray |
Array of Double
|
Long |
64-bit signed integer |
LongArray |
Array of Long
|
ULong |
64-bit unsigned integer |
ULongArray |
Array of ULong
|
String |
String of characters |
Serializable |
Custom serializable objects |
Enum |
Entry of any Enum
|
val kmPrefs = KMPrefs("your_storage_path") // create an instance
kmPrefs.store(
key = "constant", // the key of the value to store
value = 3.14159265359 // a primitive value to store
)Under the hood KMPrefs works with the kotlinx-serialization library
so it is required to import both the library and the plugin to correctly store and retrieve custom objects
@Serializable // required
data class Car(
val plate: String,
val hp: Int
)val kmPrefs = KMPrefs("your_storage_path") // create an instance
// create the instance to store
val carToStore = Car(
plate = "AA000AA",
hp = 450
)
// store the created instance
kmPrefs.store(
key = "your_key",
value = carToStore
) To safeguard sensitive data (such as token, ids, etc...) you can do as follows to encrypt values before their storage:
val kmPrefs = KMPrefs("your_storage_path") // create an instance
kmPrefs.store(
key = "constant", // the key of the value to store
value = 3.14159265359, // a primitive value to store,
isSensitive = true // the value will be stored encrypted
)val constant: Double? = kmPrefs.retrieve(
key = "constant",
defValue = 1.6180339887 // a default value to use whether the searched one is not stored yet
)// retrieve the car
val carToStore: Car = kmPrefs.retrieve(
key = "your_key",
deserializer = ,// custom deserializer to use during the retrieve whether the type is not explicit
defValue = Car(
plate = "not_found",
hp = 0
) // a default value to use whether the searched one is not stored yet
)To correctly retrieve and use a sensitive data previously stored you can follow the below guide
If your project does not target the Web platform you can normally use the retrieve method to retrieve the sensitive
data and then using it:
val constant: Double? = kmPrefs.retrieve(
key = "constant",
defValue = 1.6180339887, // a default value to use whether the searched one is not stored yet
isSensitive = true // the value will be retrieved decrypted
)Otherwise, if your project targets the Web platform you have to use the consumeRetrieval method to retrieve the
sensitive data and then consuming it:
kmPrefs.consumeRetrieval<Double>(
key = "constant",
defValue = 1.6180339887, // a default value to use whether the searched one is not stored yet
isSensitive = true, // the value will be retrieved decrypted
consume = { retrievedValue ->
println(retrievedValue) // decrypted value locally retrieved
}
)With the removeValue method you can remove a preference previously stored, it has no effect if the specified key is not
used by any preference
kmPrefs.removeValue(
key = "constant"
) With the clearAll method you can remove all the preferences currently stored by the library:
kmPrefs.clearAll() With the hasKey method you can check whether a key has been previously used to store a preference or whether a
specific preference is currently stored:
kmPrefs.hasKey(
key = "your_key"
)Check out the library documentation here!
If you need help using the library or encounter any problems or bugs, please contact us via the following links:
Thank you for your help!
If you want support project and developer
| Crypto | Address | Network |
|---|---|---|
| 3H3jyCzcRmnxroHthuXh22GXXSmizin2yp | Bitcoin | |
| 0x1b45bc41efeb3ed655b078f95086f25fc83345c4 | Ethereum | |
| AtPjUnxYFHw3a6Si9HinQtyPTqsdbfdKX3dJ1xiDjbrL | Solana |
If you want support project and developer with PayPal
Copyright © 2026 Tecknobit