How to perform Crud operation using SQLite Database for student info

This  Method  is also called the CRUD Method. Where we can do insert,update ,delete and fetch the data.And the query of the database is similar to the SQL.

This Database is used to store the data offline when we don’t need to use online database.

 

 

 

Student Mark sheet in Database With Example:

  • First We Have to create the design file like this.

Main_activity.xml

  • Now we have to create the two java class first one is DBHelper.java and second one is DBManager.java
  • We have to create DBHelper.java class to create the database and table in this java class we have to create the database ,table and we also have to extend this class with SQLiteOpenHelper. And this method overwrite two method which OnCreate() and  OnUpgrade() Method.
  • And we also create the DBManager class for the insert ,update ,delete and fetch here we can write code for those method and we can use content value for the insert and update.

DBHelper.java

DBManager.java

  • Now For insert,update, delete and fetch the data we have to do some coding in main activity as bellow.

MainActivity.java

OutPut:

  • Now we will run the program using the emulators like genymotion otherwise Android Studio inbuild Emulator or anything else bt we can’t use our phone as Emulator.

  • After Writing the name and Post and salary we have to click first on cal button so it will automatically count grade,Percentageand  total as per our coding and then click on the insert button to insert the data.
  • After that to sotore the database we have to open the Android Device Moniter you can open it using this path (Tools-Android-Android Device Moniter).
  • After opening the Device monitor select you device emulator and select File Explorer and then click the data folder and after that again click the data folder which is in data folder and select your package name and inside that package your database is store that you can save anywhere.
  • You and see the data base in the Android device monitor in the below.

  • After Saving that database you can’t see in table format if You want to see that in table format in that case you have to download the DB Browser for DQLitedatabase
  • After Downloading this you have to just open your data base and click in the Browse Data to see table format.

 

Leave a Reply

Your email address will not be published. Required fields are marked *