Hello, everyone It's been a while since I stopped by.
I'd like to ask you a question about Shared Preferences on Android.
I don't mean to ask you how to use it
Usually, when sharing values stored in variables between classes, we used Setter/Getter.
If you save it in Shared Preferences, which is stored inside the app, the value of the class here and there is
It's easy to bring. For example, when connecting to a server after logging in,
Use Shared Preferences for key values used or values to temporarily store and use in the app
I'm using it.
Of course, this value is reset to null when the logout or app is terminated.
What I'm curious about is that when there are more variables using Shared Preferences,
I wonder if there is anything bad about performance or security.
It's been a long day, but it's still pretty cold.
Developers, take care of your health. Thank you for reading the long question.
android variable
Shared Preferences internally stores it in an XML file, but it works by caching all the information in memory, so it's not expensive enough to worry about performance. It provides an API that can be written to a file in Async when saving values. Please refer to the link below for this part.
In the case of security, there is no more vulnerability because it is SharePreferences. I don't think it'll be too much if it's the same security level as the database Sqlite. (In fact, if you want to open it somehow, you can open it.)
There is a library that can be processed in a way that encrypts the Key/Value when stored in the SharesPreferences file. I think we can consider this if necessary.
© 2024 OneMinuteCode. All rights reserved.