Prerequisite

If you not understand this lectureAndroid SQLite get a single row from table.You should also read my previous lectures  Android how can add data into SQLite and Android SQLite how can retrieve data. After reading these lecture you will also able retrieve a single row from database.

Introduction

In this lecture well we describe how can retrieve a single row from Database in android studio.And also describe what is SQLite.why we can use it.After Reading this lecture you will understand how can Retrieve single row from Database in android And i hope you will create Database of your application and also retrieve single row from database after reading this series.

What is SQLite

SQLite is a embedded (RDBMS) Stand for Relation Database Management system.Most relation database such as ORA-CAL and SQL are example that are working independently and store the information .SQLite is referred to as embedded because it is provided in the form of a library that is linked into applications.The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private.There is no sever that are running in the background.All the Database function are perform internally.

Description of Retrieve of Single row

In previous lecture we will get all the information from database.But in this lecture we will get only one row from database.For get a one row form a database we use some condition with where clause.First of all we create project in android studio.Every project contain two file first is java class file and second is layout XML file.And open a layout .XML file and add Edit text and button in layout.XML.When user enter a particular name for search and click on button the email and phone number related to name are appears .In a first lecture we describe how can create table and database and second lecture we describe how can retrieve all the information in database.But in this lecture we will retrieve a single row from a database.So this is a work that will done this section.please read this lecture carefully all the detail is provides step by step.For more detail about android sqlite please click on Android SQLite get a single row from tabl

Layout XML BASIC

XML Layout 

First of you will open a XML file of layout and set Linear Layout  and add  Edit text

Different property that are used in layout.xml file  explain here

  • warp_content   warp_content means height and width similar to the text that are entered.
  • Match_parent   means height and width similar to parent.
  • Edit text              The Edit Text control allows a user to enter text into an application
  • Button                  When user click on a button show information

 And Write the following code in Activity_main.XML file

         Now we create a new Layout.

  • Step 1=<- create a new Layout name Search_content_layout.XML->Right click> the ->layout folder-> select ->New option-> and click ->layout resource folder->
  • Step2=Step1->WriteName->Ok
  • In this example we are going to create a simple UI that includes only (Text  view)  with Different attributes.And Write the following code into Search_content_Layout.XML file
          Now we create a new class

  • Step3=Create new class <-SearchContantActivity ->Right click-> the ->package name ->select ->New option-> and click-> java class that will show in below. 
  • <-WriteName->Ok

      And Write the following code SearchContantActivity. java class

         Now we create a new class

  • Step4=Create new class <-UserDbHandler ->Right click-> the ->package name ->select ->New option-> and click-> java class that will show in above. 
  •  Step5=Step4->WriteName->Ok

         And Write the following code UserDbHandler. java class

And Write the following code MainActivity. java class

Run the Application

Alt Tag android sqlite delete image

Run the application and if you click on a first button then a new activity will open. This activity consists of three Edit text  and a button .When user add information click on Save button then all the information will saved in database.And if you click on second button then a new activity will open and show all the information that are save in database.And if you click on third button a new activity will open.And user enter a particular name for search  and click on button the email and phone number related to name are appears .

Alt Tag android sqlite search image

  • Agil

    I try to add new column and want to show it on searchcontact layout but when I click search button the apps force closed.