Commit 3d77288e authored by Leonardo Aramaki's avatar Leonardo Aramaki

Implemente LocalRepository using SharedPrefences

parent 7c9153f9
package chat.rocket.android.infrastructure
interface LocalRepository {
companion object {
val KEY_PUSH_TOKEN = "KEY_PUSH_TOKEN"
}
fun save(key: String, value: String?)
fun get(key: String): String?
}
\ No newline at end of file
package chat.rocket.android.infrastructure
import android.content.Context
import android.content.SharedPreferences
class SharedPreferencesRepository(context: Context) : LocalRepository {
val preferences: SharedPreferences
init {
preferences = context.getSharedPreferences("local.prefs", Context.MODE_PRIVATE)
}
override fun save(key: String, value: String?) {
preferences.edit().putString(key, value).apply()
}
override fun get(key: String): String? {
return preferences.getString(key, null)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment