Kotlin Basics: Input, Save, and Display Data in Android Applications

Akash De AlwisAkash De Alwis
1 min read

For simplicity, let's use an EditText field to collect user input and a Button to trigger the save action.

XML Layout (activity_main.xml)

Kotlin Code (MainActivity.kt)

  • Input Data: The EditText allows users to type their data.

  • Save Data: When the "Save" button is clicked, the entered data is stored in SharedPreferences using the putString method.

  • Display Data: The TextView displays the saved data, both after saving and when the app restarts (data is persistent).

0
Subscribe to my newsletter

Read articles from Akash De Alwis directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Akash De Alwis
Akash De Alwis

Undergraduate student ๐Ÿ˜Š๐Ÿคž