Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Persist the db key to storage
/**
* Save the storable instance to preferences.
*
* @param storable a storable instance
*/
fun saveToPrefs(context: Context, storable: Storable) {
val serialized = Gson().toJson(storable)
val prefs = context.getSharedPreferences("database",
Context.MODE_PRIVATE)
prefs.edit().putString("key", serialized).apply()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.