Skip to content

Instantly share code, notes, and snippets.

@ca057
Created June 16, 2022 14:32
Show Gist options
  • Save ca057/cd60dcb40a6ba289a6ccee7bc15988c6 to your computer and use it in GitHub Desktop.
Save ca057/cd60dcb40a6ba289a6ccee7bc15988c6 to your computer and use it in GitHub Desktop.

RN Coding Snippets / stuff one might need one day

Android

Reading from the default shared preferences file

// requires access to the activity
val sharedPreferencesFile = activity?.get()?.let {
    it.getSharedPreferences("${it.packageName}_preferences", Context.MODE_PRIVATE)
} ?: return
val whateverString = sharedPreferencesFile.getString("key_for_whatever_you_have_stored_there", "default value")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment