4

I am having some question, kindly help me out, following are my questions?

  • Does shared preferences data get shared across users?

  • Also can we have same widget IDs in two different users?

  • I am having a widget which any user can use. I am getting some conflicts when a guest user or a any new user is switched to. Specifically, my widget is resizeable and in order to save its state so that it can be inflated accordingly on phone restart or some refresh events. These are working perfectly for the Admin User but it behaves abnormally when a guest is added or if the user is switched.

Saty
  • 1,068
  • 11
  • 24
  • 1
    add more detail to your query I am not getting exactly – Maveňツ Jan 03 '17 at 04:58
  • You're asking multiple questions here - please split them up to make it easier for folks to answer. And as above comments mentions, please add more details. Are you talking about a user in your app? A user at the system level? – chandsie Jan 03 '17 at 05:08

1 Answers1

0

Yes shared preferences data get shared across users if we define CONTEXT MODE while creating SahredPreference for more detail you can read here for detail, and here. For widget id i think we can give same id in different users but here (i am not sure) also should be concept of Mode.

Community
  • 1
  • 1
ʌɐɥqıɐʌ
  • 137
  • 16
  • Still in doubt, when we create a new user in android then all apps behaves as it is launched for the first time. CONTEXT MODE is more of at application level. – Saty Jan 03 '17 at 05:52
  • I think it MODE_WORLD is deprecated now. So you can use OBB files (/sdcard/Android/obb) to share data across users as it is shareable between diff users. you can find a good example of it on google. hope that helps. – ʌɐɥqıɐʌ Jan 03 '17 at 06:25