Last active
August 10, 2021 16:01
-
-
Save vaibhavgoyal09/31788d888fdb40fa53ee7be4bfbb40fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override suspend fun getString(key: String): String? { | |
return try { | |
val preferencesKey = stringPreferencesKey(key) | |
val preferences = context.dataStore.data.first() | |
preferences[preferencesKey] | |
}catch (e: Exception){ | |
e.printStackTrace() | |
null | |
} | |
} | |
override suspend fun getInt(key: String): Int? { | |
return try { | |
val preferencesKey = intPreferencesKey(key) | |
val preferences = context.dataStore.data.first() | |
preferences[preferencesKey] | |
}catch (e: Exception){ | |
e.printStackTrace() | |
null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment