I am trying to make an app in android studio. I want my app to store what user types in the app in editText. Even if user opens the app after 1 week it should stay there in edit text. thanks.
Question posted in Android Studio
The official documentation can be found here.
The official documentation can be found here.
2
Answers
Steps to follow
When the app goes to idle or background save the data written in edittext with preferences check the preference when app is opened and prefill the edittext. If you want coding help then let me know. Hope this will give you and give you tha bacis
The most simple way to achieve this is by using
SharedPreferences
To detect when the user edits the value of the
editText
, useaddTextChangedListener
, and immediately store it usingSharedPreferences
The code for this is as following,The above code will save the
editText
value. To retrieve the stored value when the user opens the app later, the following code shall be used,