How to Create DataBase in Android – Mobile App Development, Android App Development, iphone App Development class="post-template-default single single-post postid-4098 single-format-standard wp-custom-logo"

How to Create DataBase in Android

Download APK Download Source Code Contact Us

Create a new project in Android Studio

File – New Android Project

How to Create DataBase in Android

How to Create DataBase in Android

Using of DataBaseHelper Class

Once the projected is created create a new class in your project src directory and name it as click on src/package – New – Class)

Now extend your class from SQLiteOpenHelper.

public class DataBaseHendler extends SqLiteOpenHelper {

After extends your class from SqLiteOpenHelper you need to override two method onCreate() and onUpgrade.

onCreate():-These is where we need to write create table statements. This is called when database is created.

onUpgrade():-This method is called when database is upgraded like modifying the table structure, adding constraints to database .

Create DataBaseHelper Class
Right click on package Name – New – Java Class

For Ex:-

[code lang=”js”]
public class DataBaseHelper extends SQLiteOpenHelper {
// Database version name
private static final int DATABASE_VERSION = 1;
// Database name
private static final String DATBASE_NAME = "regForm.db";

public static final String TABLE_NAME = "user";
public static final String USER_ID = "_id";
public static final String NAME = "name";
public static final String EMAIL = "email";

public DataBaseHelper(Context context) {
super(context, DATBASE_NAME, null, DATABASE_VERSION);

//Creating Tables
public void onCreate(SQLiteDatabase db) {
String CREATE_USER_TABLE = "create table " + TABLE_NAME
+ " ( " + USER_ID + " integer primary key autoincrement,"
+ NAME + " TEXT,"
+ EMAIL + " TEXT,"
// Upgrading database
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {



Inserting new Record in the Table

To Insert a new Record in Table we need to create an Object of ContentValues class and put the Values in this like:

[code lang=”js”]
// Assign value for each row
ContentValues values = new ContentValues();
values.put(KEY_NAME, contact.getName()); // Contact Name
values.put(KEY_PH_NO, contact.getAddress()); // Contact Address
// Insert the row into your table
db.insert(TABLE_CONTACTS, null, values);
db.close(); // Closing database connection

Reading Row

For Ex:

How to Create DataBase in Android

Deleting Record

[code lang=”js”]
deleteContact() will delete single contact from database.
public void deleteContact(Contact contact){
SqLiteDatabase db=this.getWriteableDatabase();
Db.delete(TABLE_CONTACTS, KEY_ID + “ ?”, new String [] { String.valueof(contact.getid)});

How to Create DataBase in Android
How to Create DataBase in Android
How to Create DataBase in Android

Download APK Download Source Code Contact Us

Warning: _() expects exactly 1 parameter, 2 given in /home2/mobilemeri7/public_html/wp-content/themes/mobilemerit/comments.php on line 28

Write a Reply or Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Crack Accounts admin panel bypass Tiktok hackleme sitesi Nulled Scripts Nulled Script ioncube decoder iphone sızma valorant hackleme Crack script Brute force programı Brute force yapma internetten para kazanma Evde para kazanmanın yolları Öğrenciler için internetten para kazanma yolları valorant combo Brute force programı Açıklı siteler SQL Açıklı siteler CMS Brute Force kaçağı bulmasu tesisatçısıjigolo siteleri arkadaş bulankara nakliyatankara nakliyatistanbul nakliyatgay sohbetbatak oynatavla oynagabile sohbetokey oynaoyunlar oyna #yaslikurt# sex geschichten sex geschichten brazzers rot media instagram banned service Hack haber Hacklink satışı Hacklink Çift faktör kıran telif scripti instagram hackleme sitesi instagram hackleme sitesi Bahis scripti Hack sitesi Crack forum Crack forum Crack Crack Forum instagram hackleme sitesi instagram hesap kapatma instagram hesap kapatma formları instagram hesap kapatma method instagram faktör geçme instagram faktör kırma instagram telif scripti Instagram Telif Scripti 2022 instagram hackleme sitesi apili telif scripti Facebook Temalı Telif Scripti