jeroentrappers / flutter_keychain

A flutter plugin for secure storage on Android via KeyStore and iOS via Keychain
Other
56 stars 41 forks source link

Android - Add commits() for delete and clear #1

Closed bkayfitz-cara closed 5 years ago

bkayfitz-cara commented 5 years ago

On some android devices, like the Samsung Galaxy S9, if you don't explicitly call commit, shared prefs will not be updated and it will be like you never deleted the key.

"remove" -> {
    preferences.edit()
    .remove(call.key())
    .commit()
    result.success(null)
}
"clear" -> {
    preferences.edit()
    .clear()
    .commit()
    result.success(null)
}

You may also want add @SuppressLint("ApplySharedPref") to the method since android studio complains about using commit() over apply(). But in this case, I would think that commit (which synchronously) is the correct behaviour.

jeroentrappers commented 5 years ago

Thank you very much for the suggestion. I've applied it and bumped the version. My apologies for the delay. I missed some notifications.