Group Services: Technology Consulting
phone +91-9999-283-283/9540-283-283
email info@sisoft.in

SQLite is Android's version of SQL. SQL - Structured Query Language - is a commonly used query langauge to store,access and edit data dynamically. SQLite is basically an entire SQL defined using Classes and methods defined in Android SDK. Developers can make use of these classes and methods to perform query functions on the data stored in their apps. In this app, we will be making two buttons - one for adding text records and another for views those text records. these twxt records are getting stroed in a database handled through SQLite.

Steps to develop this can be summarized below -

Used Concepts & Used Version: (Version of Android API)

Now, let’s begin the development...

1. Make a new project

2. HomeActivity.class layout

3. AddRecordsActivity.class

When the user clicks on Submit button, inesert_mybooks(View v) gets called which then calls dbh.insert_mybooks() method. This method is present in DB Helper class(mentioned later) which finally saves the entries in the database.

4. Layout for AddRecordsActivity.class

5. DBhelper.class

a) Inside DBHelper.class we create a constructor for creating instances of the database

b) OnCreate method ensures that whenever the database is prepared it saves a few initial values in it which can be used to display. We have entered 3 values here which user can view when they launch the app.

c) All the statements used in SQLite are same as SQL. You just need to know the right method and class to execute those statements. Like in this case, you can see that we are using execSQL() method which contains same SQL statements that you would use in SQL queries otherwise.

d)Here we have also defined insert_mybooks(String title, String author, String st) method that finally saves the data in database. ContentValues is a class that helps us to submit data in one go inside the database.

e) We use getReadableDatabase() and getWritableDatabse() to read and write data respectively.

f) There is another method listRecord() which provides a cursor object that can traverse through the database.

6. ListingActivity.class

a)In the above activity, we initiate a cursor object during onStart() and move the cursor to the first position in the records.

b) Based upon what button user clicks on - previous/next - Cursor movements are decided.

7. Layout for ListingActivity.class

Output when the App is run -

  1. User is presented with two options to Add Record and View Records.
  2. When user clicks on Add Records, they are taken to the AddRecordsActivity.class to add records through EditTexts
  3. If the user click on View Records button , they are directed to another screen where they can view records through previous/next buttons.
  4. In case the user reaches at the end of the list, they are informed through a Toast message.