Storing data in SQLite Database in android
Saved by @Awais malik #android #java
Step 0: First of all we create a Class and extend it from SQLiteOpenHelper Class and create database
Step 1: Now we override onCreate and onUpgrade methods and create table in our database here i am creating a table for storing profiles #Remember this code will reside in the class which we created in step 1
Step 2: As our table is created in database now we store data into that table for that purpose i am creating a method named as addProfile
Step 3: Now we create DTO Class for passing data to Database Class
Step 4: Now Let suppose we created an activity which ask user to provide userName and profileName and when user click button it stores data into database we will do it as follow Assume user already created activity if you didn't created yet then create it. Let suppose activity name is MyProfile
In this tutorial we learn about how to create local Database in android using SQLite and store values in it
,
Comments