Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can I store anything in SharedPreferences?

I am creating a file explorer to synchronize an ftp directory on my phone, I would like that at each synchronization I can know which files is new, and this even after closing my app and resume at the next session. I thought of saving a Array with all my new files and compare it in the adapter to know if it has already been open or not. But for this I need to store this array somewhere, can I store it in SharedPreferences? Is it this the best way to go?

Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No, you can only store boolean, int, float, long, string, and sets (not arrays, sets so no duplicate entries) of strings. If you need more than that, you need to use your own serialization method.

Shared preference docs: https://developer.android.com/reference/android/content/SharedPreferences

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading