Home > Software design >  how to save last entered edit text value in Android App?
how to save last entered edit text value in Android App?

Time:10-22

I am creating a simple android app with login credentials as username and password in edit text. How can i save last entered username and password in app , when user try to relogin. How should i handle it. Do i have to store them in android app or it can be taken care of my android. Any help would be highly appreciated.

<EditText
   android:id = "@ id/editText2"
   android:layout_width = "wrap_content"
   android:layout_height = "wrap_content"
   android:inputType = "textPassword" />

<EditText
   android:id = "@ id/editText1"
   android:layout_width = "wrap_content"
   android:layout_height = "wrap_content"
/>

CodePudding user response:

The easiest way is using Shared Preferences.

But it's not safe to store credentials raw.

CodePudding user response:

You can do it in different ways:

  • store data in Shared Preferences locally.
  • save data locally again but with databases like Room.
  • make online database and connect to it with Retrofit or something like that. (this one is a good choice when it comes to bigger projects)
  • Related