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

后端 未结 14 2440
隐瞒了意图╮
隐瞒了意图╮ 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:02

    About the simplest way to store a single preference in an Android Activity is to do something like this:

    Editor e = this.getPreferences(Context.MODE_PRIVATE).edit();
    e.putString("password", mPassword);
    e.commit();
    

    If you're worried about the security of these then you could always encrypt the password before storing it.

提交回复
热议问题