Creating and storing Password in Android

808 Views Asked by At

I am developing an android application that allows access to its contents when the user enters the password. I do not want to include a database, i just want the application to be able to create a new password for the user and also the user can be able to change the old password to a new one.

I have created two classes and one xml. But what i want now is to make the EdittextPreference pop up 3 edittext rather than the usual 1 so that the user can be able to change the old password. See the code so far

<EditTextPreference android:key="showPreferences"
    android:title="Preferences"
    android:summary="Admin Data"
    android:defaultValue="Nothing"/>

<EditTextPreference android:key="editPassword"
    android:title="Change Password"
    android:summary="This allows you to change password"
    android:defaultValue="Nothing"/>

package my.preferences;

import android.os.Bundle; import android.preference.PreferenceActivity;

public class SetPrefs extends PreferenceActivity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);
}

}

3

There are 3 best solutions below

0
On

Store user password in Shared Preference..

The SharedPreferences class provides a general framework that allows you to save and retrieve persistent key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: booleans, floats, ints, longs, and strings. This data will persist across user sessions (even if your application is killed).

Android - Shared Preferences

0
On

If you dont want database then, SharedPreferene to store passwords. For code, please show your effort.

0
On

You can store username and password in a file and encrypt it's content and decrypt that when you need it. Shared preference is another good option you can choose

Here is an example of how to encrypt and how to decrypt something: