Notes app is a tool used for creating, updating, and discarding short text notes. It serves various purposes such as maintaining to-do lists, jotting down important information for future reference, and more. This app proves to be highly useful when quick access to notes is needed.
Let's delve into creating an Android application to understand the process of developing a simple Notes App. In this tutorial, we will build a Notes App that enables users to add, remove, and edit data. The project will be implemented using the Java programming language.
The user can add any data, remove any data as well as edit any dataA sample GIF illustrating the functionality of the app is provided below to give you an overview of what we aim to achieve in this tutorial. Note that Java will be the language used for this project.JavaStep 1: Create a New Project
To initiate a new project in Android Studio, follow the steps outlined in "How to Create/Start a New Project in Android Studio." Ensure that you choose Java as the programming language for this project.
Step 2: Working with the activity_main.xml file
In the activity_main.xml file, incorporate a ListView and a TextView. The ListView will display the list of automatically saved notes, while the TextView will exhibit the GFG text. Below is the complete code snippet for the activity_main.xml file.
activity_main.xmlimport android.content.Context; | import android.content.Intent; |
import android.content.SharedPreferences; | import android.os.Bundle; |
import android.text.Editable; | import android.text.TextWatcher; |
import android.widget.EditText; | import androidx.appcompat.app.AppCompatActivity; |
import java.util.HashSet; |
Step 5: Working with the MainActivity.java file
import android.content.Context; | import android.content.DialogInterface; |
import android.content.Intent; | import android.content.SharedPreferences; |
import android.os.Bundle; | import android.view.Menu; |
import android.view.MenuInflater; | import android.view.MenuItem; |
import android.view.View; | import android.widget.AdapterView; |
import android.widget.ArrayAdapter; | import android.widget.ListView; |
import androidx.annotation.NonNull; | import androidx.appcompat.app.AlertDialog; |
import androidx.appcompat.app.AppCompatActivity; | import java.util.ArrayList; |
import java.util.HashSet; |
Now set up all the things in the MainActivity.java file. Calling the NoteEditorActivity.java code, join all the XML code to Java and run the app. Below is the complete code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.
MainActivity.javaOverall, MainActivity.java forms the backbone of the note-taking app, managing note creation, editing, and deletion functionalities.