Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
muddassir235 authored Sep 7, 2020
1 parent 1fee31d commit 29753f7
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,39 @@ save("mykey", arrayListOfAnySerializableObject) // An ArrayList of any Serializa
#### Load from SharedPreferences
Load any saved boolean, int, long, float, string, or array of (boolean, int, long, float, string), a Serializable Object, or an ArrayList of any Serializable Objects from SharedPreferences within a Context. (Throws unsupported type exception in case the object is not serializable.)
```kotlin
load<Boolean>("mykey")
load<Int>("mykey")
load<Long>("mykey")
load<Float>("mykey")
load<String>("mykey")
load<Array<String>>("mykey") // Arrays of all primitive types are supported
val value = load<Boolean>("mykey")
val value = load<Int>("mykey")
val value = load<Long>("mykey")
val value = load<Float>("mykey")
val value = load<String>("mykey")
val value = load<Array<String>>("mykey")
.
.
.
load<MySerializableObject>("mykey") // Any Serializable object can be loaded.
load<ArrayList<MySerializableObject>>("mykey") // An ArrayList of any Serializable Object can also be loaded.
val value = load<MySerializableObject>("mykey")
val value = load<ArrayList<MySerializableObject>>("mykey")
```
#### Safe Save and Load
#### Delete from SharedPreferences
Load any saved boolean, int, long, float, string, or array of (boolean, int, long, float, string), a Serializable Object, or an ArrayList of any Serializable Objects from SharedPreferences within a Context. (Throws unsupported type exception in case the object is not serializable.)
```kotlin
delete<Boolean>("mykey")
delete<Int>("mykey")
delete<Long>("mykey")
delete<Float>("mykey")
delete<String>("mykey")
delete<Array<String>>("mykey")
.
.
.
delete<MySerializableObject>("mykey")
delete<ArrayList<MySerializableObject>>("mykey")
```
#### Safe Save, Load and Delete
Safe versions of the above save and load functions which avoid/ignore any exceptions.
```kotlin
safeSave("mykey", myObject) // Does nothing if it fails
safeLoad<MyObject>("mykey") // Returns null in case any exception occurs
safeDelete<MyObject>("mykey") // Does nothing if it fails
```
#### Create Intent
Create an intent of an Activity from within a context.
Expand Down

0 comments on commit 29753f7

Please sign in to comment.