Reputation: 435
Is it safe to use SharedPreferences
if I have 2 processes in my app and I will create 2 separate preference files? I mean 1 file for main process and 2nd file for 2nd process. And the 2 processes wouldn't access other than their own file?
For creating separate files I would use:
Context.getSharedPreferences(String name, int mode)
, where name is name of the file.
Upvotes: 0
Views: 284
Reputation: 1007276
So long as you are careful and do not accidentally try using the same SharedPreferences
on both processes, what you describe should be OK.
Personally, I would consider using some other form of file (e.g., JSON, SQLite), as I'm not certain what the advantage is of using SharedPreferences
here.
Upvotes: 0