iamMehedi / Secured-Preference-Store

A cryptography library and a SharedPreferences wrapper for Android that encrypts the content with 256 bit AES encryption. The Encryption key is securely stored in device's KeyStore.
563 stars 97 forks source link

Remove sharedPreferences #19

Closed fermedina closed 7 years ago

fermedina commented 7 years ago

Hi!

How can I remove my sharedPreferences?

iamMehedi commented 7 years ago

Just the way you'd remove values from the standard SharedPreferences: https://stackoverflow.com/questions/8034127/how-to-remove-some-key-value-pair-from-sharedpreferences

fermedina commented 7 years ago

But I would like remove a specific entry. I have seen that the keys are encrypted and I don’t know how to remove the key that I would like. Can you help me?

iamMehedi commented 7 years ago

As you don't provide hashed key to store or retrieve a value, you don't need to provide the hashed key for removing a value. Just provide the actual key and the library will handle hashing it appropriately.

fermedina commented 7 years ago

But the library doesn't have any method to remove a key/value pair. I want to remove all key/value pair except one. But I don't know how to know which key/value pair doesn't remove, because te key is also encrypted

iamMehedi commented 7 years ago

SecuredPreferenceStore is a SharedPreferences implementation hence has all the methods that a SharedPreferences is supposed to have and behaves similarly.

to remove a key and associated value call:

SecuredPreferenceStore prefStore = SecuredPreferenceStore.getSharedInstance(getApplicationContext());
prefStore.edit().remove("key").apply();