What is the most appropriate way to store user settings in Android application

后端 未结 14 2102
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 05:38

I am creating an application which connects to the server using username/password and I would like to enable the option \"Save password\" so the user wouldn\'t have to type

14条回答
  •  花落未央
    2020-11-22 06:11

    I know this is a little bit of necromancy, but you should use the Android AccountManager. It's purpose-built for this scenario. It's a little bit cumbersome but one of the things it does is invalidate the local credentials if the SIM card changes, so if somebody swipes your phone and throws a new SIM in it, your credentials won't be compromised.

    This also gives the user a quick and easy way to access (and potentially delete) the stored credentials for any account they have on the device, all from one place.

    SampleSyncAdapter is an example that makes use of stored account credentials.

提交回复
热议问题