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 DataBaseHendler.java(Right click on src/package – New – Class)

Now extend your DatabaseHandler.java 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
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_USER_TABLE = "create table " + TABLE_NAME
+ " ( " + USER_ID + " integer primary key autoincrement,"
+ NAME + " TEXT,"
+ EMAIL + " TEXT,"
db.execSQL(CREATE_USER_TABLE); }
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

}
}

[/code]

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
}
[/code]

Reading Row

For Ex:

How to Create DataBase in Android

Deleting Record

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

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.

Cracked Accounts Free Netflix Accounts VPN Proxy Shares Hack Programları Hack dökümanları Hack methodsları Wordlist Combolist Warez Scriptler Download Warez Files WhatsApp Numara çekme +90 Abazalardan Para kazanma Telegram Mavi tik alma 2022 Numara sorgulama Azuere Aws Sanal Kart Method WhatsApp vurma Güncel Method 2022 Bedava .Com .Org .Net VDS Premium Host YouTube Sahte Telif Methodu Tıklama hilesi ile para kazanmak Azure Hack method Pubg Mobile Uc Almak Hedef Kişinin herşeyini öğrenmek instagram Telif taslağı 2022 Ölüm Belgesi ile instagram hesap kaptma instagram form ile ebedi hesap kapatma instagram taklitsiz hesap kapatma instagram Çift faktör geçme instagram tiktok hesap çalma method instagram 2 Faktörlü doğrulama geçme instagram hesap kapatma 2022 instagram rever kırmak instagram Revert Kırma Abaza Dayı Methodu Aylık Dolar kazamak 1500 dolar instagram Çalmak istiyorum instagram düşmeyen takipçi instagram hackleme sitesi Whatsapp Kapatma %100 Abaza tokatlayarak para kazanmak Spotify ile para kazanma Günde 100 tl kazanma sınırsız kazanç Yatakta yatarak para kazanma YouTube izlenme arttırme yöntemi Oturduğun yerde para kazanma yöntemi Discord Hack tool Discord hack programları Cerebrus Rat v2 kodları PP Takipçi Çeken Telif Scripti Facebook profil kapatma methodu 2022 instagram yapay ile banned methodu instagram hesap satşı Sosyal medya hesap satışı Sosyal medya hack Leak Forum Crack Forum Cracking Forum Warez Forum Hack Forum illegal Forum Hacking Forum instagram Forum instagram Forumu Hacklink Hack forum php Shell indir Hack haber
https://www.ankihlasnakliyat.com/jigolosahibinden.comankara nakliyatankara nakliyatistanbul nakliyatankara nakliyatJigolodiyarijigolo sitesigerçek jigolo sitesijigolo sitelerimjigolo şirketlerijigolo sitelerijigolo başvurujigolo arayan kadınlara ulaşKocuceKo cuce