Skip to content

Instantly share code, notes, and snippets.

@ayetolusamuel
Created November 27, 2020 15:52
Show Gist options
  • Save ayetolusamuel/cfe765433058a6d0de877b76d0065434 to your computer and use it in GitHub Desktop.
Save ayetolusamuel/cfe765433058a6d0de877b76d0065434 to your computer and use it in GitHub Desktop.
//runtime permission check for location
fun checkPermission(): Boolean{
return ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
}
//request permission
fun requestPermission(){
ActivityCompat.requestPermissions(this,
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION),
locationPermissionCode)
}
@ayetolusamuel
Copy link
Author

fun Context.deleteSharePreference(key: String) {
val settings: SharedPreferences = getDefaultSharedPreferences(this)
settings.edit().remove(key).apply()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment