Actually, I have a doubt regarding SharedPreferences in android. I have started learning Android a few days back and I am creating a SignUp Page for now, for that, I have searched the internet and got some ideas and now I am using multiple shared preferences in my code which I am thinking it would be a bad practice. So, I just wanna know, what happens to the Application if we create multiple shared preferences in the code.
Asked
Active
Viewed 527 times
1
-
why would that be a bad practice? – Tim Jul 12 '19 at 07:25
-
no problem you can create multiple shared preferences https://stackoverflow.com/questions/56824973/saving-a-user-session-after-logging-in-with-sql-server/56825141#56825141 – user311086 Jul 12 '19 at 07:25
-
Why do you think it is a bad practice? Please give your thoughts on that. – Jude Osbert K Jul 12 '19 at 07:27
3 Answers
2
This will just result in multiple SharedPrefenrences files (XML) in the data folder of your app. This is neither a problem nor a bad practice. If you have larger sets of structured data, consider using a database (e.g. SQLite/Room).

Tidder
- 1,126
- 1
- 7
- 15
0
With the concept of consuming more memory we shouldn't use SharedPreference to store large amounts of data, Alwayas use SQL DB in android for that. Multiple sharedpreference is good because , you can store data seperate for different sections within the app if it doesn't need to be shared. Shared preference is just a xml file with key value pair. So if you store only simple key value pairs, its okay to have multiple shared preferences. But be logical in your decision, dont just do that because you can

Jude Osbert K
- 940
- 9
- 22