1# UserFileManager
2
3This class is used to generate file paths and SharedPreferences that is compatible for specific OS
4users in SystemUI. Due to constraints in SystemUI, we can only read/write files as the system user.
5Therefore, for secondary users, we want to store secondary user specific files into the system user
6directory.
7
8
9## Usages
10
11Inject UserFileManager into your class.
12
13### fun getFile(fileName: String, userId: Int): File
14Add a file name and user id. You can retrieve the current user id from UserTracker. This will
15return a java.io File object that contains the file path to write/read to.
16
17i.e. `fileManager.getFile("example.xml", userTracker.userId)`
18
19### fun getSharedPreferences(fileName: String, mode: Int, userId: Int): SharedPreferences
20Add a file name, user id, and PreferencesMode. You can retrieve the current user id from
21UserTracker. This returns SharedPreferences object that is tied to the specific user. Note that if
22the SharedPreferences file does not exist, one will be created automatically. See
23[SharedPreferences documentation](https://developer.android.com/reference/android/content/Context#getSharedPreferences(java.lang.String,%20int))
24for more details.
25
26i.e. `fileManager.getSharedPreferences("prefs.xml", userTracker.userId, 0)`
27
28## Handling User Removal
29
30This class will listen for Intent.ACTION_USER_REMOVED and remove directories that no longer
31corresponding to active users. Additionally, upon start up, the class will run the same query for
32deletion to ensure that there is no stale data.
33
34