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
CodePudding user response:
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
CodePudding user response:
The only two thing you have to save are the date-times of last two synchronizations.
The date-time of last new files fall in between them.
You can save those two values in shared preferences.
Important is if you keep file times at synchronization.
And of course you can save a string array to shared preferences. Just concatenate all strings (like a .csv line) and save this line.
Further: if you dont keep file time then you only have to remember last date-time to know which files are new.