SlideShare a Scribd company logo
1 of 13
Think Android
Lesson : Sqlite Multiple Tables
By : Danang Kukuh P
What is Sqlite?
 SQLite is an Open Source database. SQLite supports
standard relational database features like SQL
syntax, transactions and prepared statements.
Sqlite in Android
 SQLite is embedded into every Android device. Using an
SQLite database in Android does not require a setup
procedure or administration of the database.
 You only have to define the SQL statements for creating and
updating the database. Afterwards the database is
automatically managed for you by the Android platform.
Sqlite Multiple Tables
 I explained how to use SQLite database in your android
application. But that covered the scenario, only when you
have one table in the database. I am getting lot of queries
about handling the sqlite database when it is having multiple
tables.
Introduction to the project

Database Design
Film

Kategori

FIELD

TYPE

KEY

FIELD

TYPE

Id

INTEGER

PK

Id

INTEGER PK

Name

TEXT

name

TEXT

created_at

DATETIME

created_at

DATETIME

Film_kategori
FIELD

TYPE

KEY

Id

INTEGER

PK

Film_id

INTEGER

Kategori_id INTEGER

KEY
Example Data
Kategori

Film
Id

Name

Id

Name

1

Ketika Jomblo Bertasbih

1

Action

2

Petualangan si gundul

2

Horror

3

Transformer

3

Adventure

4

Sadako

4

Drama

5

3 Hati 2 Dunia 1 Cinta
Film_Kategori
Id
1

Film_id
1

Kategori_id
4

2

2

3

3

3

1

4

4

2

5

5

4
Let’s Start a New Project
 Click New
in the toolbar. In the window that appears, open
the Android folder,
select Android Application
Project,
and click Next. Figure 1.
The New Android App
Project wizard in Eclipse.
Creating Model Class for Tables
 Create Class Film.java and Kategori.java in package model
And create constructor, setter and getter
Creating DatabaseHelper
 Create Class DatabaseHelper.java in package helper
 And create CRUD(Create, Read, Update, Delete) Operations
MainActivity
 In the below I just created sample Kategori and Film data and
performed the all the operations by calling the methods which
we prepared in DatabaseHelper class.
Run App….
Check data in Database
 I Check data in Database Sqlite with Sqlite Editor
Source Code?
 Check Source Code in My GitHub
 https://github.com/dpapayas/SqliteMultipleTables
Thanks 

More Related Content

What's hot

android sqlite
android sqliteandroid sqlite
android sqlite
Deepa Rani
 
Inno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code StructureInno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code Structure
MySQLConference
 
R2서버정진욱
R2서버정진욱R2서버정진욱
R2서버정진욱
jungjinwouk
 
[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드
[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드
[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드
MinGeun Park
 
Oracle db architecture
Oracle db architectureOracle db architecture
Oracle db architecture
Simon Huang
 

What's hot (20)

Chapter 6 the django admin site
Chapter 6  the django admin siteChapter 6  the django admin site
Chapter 6 the django admin site
 
android sqlite
android sqliteandroid sqlite
android sqlite
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Hibernate Basic Concepts - Presentation
Hibernate Basic Concepts - PresentationHibernate Basic Concepts - Presentation
Hibernate Basic Concepts - Presentation
 
Java garbage collection & GC friendly coding
Java garbage collection  & GC friendly codingJava garbage collection  & GC friendly coding
Java garbage collection & GC friendly coding
 
Oracle architecture
Oracle architectureOracle architecture
Oracle architecture
 
[0602 박민근] Direct2D
[0602 박민근] Direct2D[0602 박민근] Direct2D
[0602 박민근] Direct2D
 
M|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write PathsM|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write Paths
 
12. oracle database architecture
12. oracle database architecture12. oracle database architecture
12. oracle database architecture
 
Inno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code StructureInno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code Structure
 
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line KeystrokesEfficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
 
Sql Server Management Studio Tips and Tricks
Sql Server Management Studio Tips and TricksSql Server Management Studio Tips and Tricks
Sql Server Management Studio Tips and Tricks
 
R2서버정진욱
R2서버정진욱R2서버정진욱
R2서버정진욱
 
PostgreSQL Advanced Queries
PostgreSQL Advanced QueriesPostgreSQL Advanced Queries
PostgreSQL Advanced Queries
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
Jetty Vs Tomcat
Jetty Vs TomcatJetty Vs Tomcat
Jetty Vs Tomcat
 
20 Tips and Tricks with the Autonomous Database
20 Tips and Tricks with the Autonomous Database 20 Tips and Tricks with the Autonomous Database
20 Tips and Tricks with the Autonomous Database
 
[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드
[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드
[Gpg2권 박민근] 3.2 게임 객체 ai를 위한 마이크로 스레드
 
Oracle db architecture
Oracle db architectureOracle db architecture
Oracle db architecture
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 

Viewers also liked

Android Radio streaming
Android Radio streamingAndroid Radio streaming
Android Radio streaming
Agus Haryanto
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for Android
Jakir Hossain
 

Viewers also liked (20)

BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in Android
 
Asynctasks
AsynctasksAsynctasks
Asynctasks
 
Seminar Android as your Smart Future
Seminar Android as your Smart FutureSeminar Android as your Smart Future
Seminar Android as your Smart Future
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database Tutorial
 
FYPJ - Cerebral Android App Development (Report)
FYPJ - Cerebral Android App Development (Report)FYPJ - Cerebral Android App Development (Report)
FYPJ - Cerebral Android App Development (Report)
 
Getting Started With ANDROID
Getting Started With ANDROIDGetting Started With ANDROID
Getting Started With ANDROID
 
Android Radio streaming
Android Radio streamingAndroid Radio streaming
Android Radio streaming
 
Android Dialogs Tutorial
Android Dialogs TutorialAndroid Dialogs Tutorial
Android Dialogs Tutorial
 
android app development training report
android app development training reportandroid app development training report
android app development training report
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for Android
 
(続) Effective SQLite for Android
(続) Effective SQLite for Android(続) Effective SQLite for Android
(続) Effective SQLite for Android
 
Android Fast Track - Database SQLite (Kamus Tiga Bahasa)
Android Fast Track - Database SQLite (Kamus Tiga Bahasa)Android Fast Track - Database SQLite (Kamus Tiga Bahasa)
Android Fast Track - Database SQLite (Kamus Tiga Bahasa)
 
Android Sliding Menu dengan Navigation Drawer
Android Sliding Menu dengan Navigation DrawerAndroid Sliding Menu dengan Navigation Drawer
Android Sliding Menu dengan Navigation Drawer
 
Belajar Android Studio Memberi Efek animasi pada Button
Belajar Android Studio Memberi Efek animasi pada ButtonBelajar Android Studio Memberi Efek animasi pada Button
Belajar Android Studio Memberi Efek animasi pada Button
 
Kenalan Dengan Firebase Android
Kenalan Dengan Firebase AndroidKenalan Dengan Firebase Android
Kenalan Dengan Firebase Android
 
Журнал чергового класу
Журнал чергового класуЖурнал чергового класу
Журнал чергового класу
 
Tutorial Android Membuat Aplikasi senter Flash light
Tutorial Android Membuat Aplikasi senter Flash lightTutorial Android Membuat Aplikasi senter Flash light
Tutorial Android Membuat Aplikasi senter Flash light
 
Android Fast Track CRUD Android PHP MySql
Android Fast Track CRUD Android PHP MySqlAndroid Fast Track CRUD Android PHP MySql
Android Fast Track CRUD Android PHP MySql
 
Belajar Android PHP MySQL Login dengan Volley
Belajar Android PHP MySQL Login dengan VolleyBelajar Android PHP MySQL Login dengan Volley
Belajar Android PHP MySQL Login dengan Volley
 
Belajar Android Membuat Katalog Produk
Belajar Android Membuat Katalog ProdukBelajar Android Membuat Katalog Produk
Belajar Android Membuat Katalog Produk
 

Similar to Sqlite Multiple Table

CA_Plex_SupportForModernizingIBM_DB2_for_i
CA_Plex_SupportForModernizingIBM_DB2_for_iCA_Plex_SupportForModernizingIBM_DB2_for_i
CA_Plex_SupportForModernizingIBM_DB2_for_i
George Jeffcock
 
Sql Azure - Sql Saturday Chicago
Sql Azure - Sql Saturday ChicagoSql Azure - Sql Saturday Chicago
Sql Azure - Sql Saturday Chicago
Aaron King
 

Similar to Sqlite Multiple Table (20)

Android development beyond the basics
Android development   beyond the basicsAndroid development   beyond the basics
Android development beyond the basics
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Os Owens
Os OwensOs Owens
Os Owens
 
Implementation of sql server based on sqlite engine on
Implementation of sql server based on sqlite engine onImplementation of sql server based on sqlite engine on
Implementation of sql server based on sqlite engine on
 
Sq lite
Sq liteSq lite
Sq lite
 
Sq lite database
Sq lite databaseSq lite database
Sq lite database
 
Sq lite
Sq liteSq lite
Sq lite
 
CA_Plex_SupportForModernizingIBM_DB2_for_i
CA_Plex_SupportForModernizingIBM_DB2_for_iCA_Plex_SupportForModernizingIBM_DB2_for_i
CA_Plex_SupportForModernizingIBM_DB2_for_i
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptxCreate an android app for database creation using.pptx
Create an android app for database creation using.pptx
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)
 
How Android Architecture Components can Help You Improve Your App’s Design?
How Android Architecture Components can Help You Improve Your App’s Design?How Android Architecture Components can Help You Improve Your App’s Design?
How Android Architecture Components can Help You Improve Your App’s Design?
 
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginnersSQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
 
Sql Azure Sql Saturday Nyc
Sql Azure   Sql Saturday NycSql Azure   Sql Saturday Nyc
Sql Azure Sql Saturday Nyc
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51
 
Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact Edition
 
Fastest offline with SQLite
Fastest offline with SQLiteFastest offline with SQLite
Fastest offline with SQLite
 
Sql Azure - Sql Saturday Chicago
Sql Azure - Sql Saturday ChicagoSql Azure - Sql Saturday Chicago
Sql Azure - Sql Saturday Chicago
 
Sql Azure - Columbus SQL PASS
Sql Azure - Columbus SQL PASSSql Azure - Columbus SQL PASS
Sql Azure - Columbus SQL PASS
 
Secrets of Enterprise Data Mining 201305
Secrets of Enterprise Data Mining 201305Secrets of Enterprise Data Mining 201305
Secrets of Enterprise Data Mining 201305
 
Android course1
Android course1Android course1
Android course1
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Sqlite Multiple Table

  • 1. Think Android Lesson : Sqlite Multiple Tables By : Danang Kukuh P
  • 2. What is Sqlite?  SQLite is an Open Source database. SQLite supports standard relational database features like SQL syntax, transactions and prepared statements.
  • 3. Sqlite in Android  SQLite is embedded into every Android device. Using an SQLite database in Android does not require a setup procedure or administration of the database.  You only have to define the SQL statements for creating and updating the database. Afterwards the database is automatically managed for you by the Android platform.
  • 4. Sqlite Multiple Tables  I explained how to use SQLite database in your android application. But that covered the scenario, only when you have one table in the database. I am getting lot of queries about handling the sqlite database when it is having multiple tables.
  • 5. Introduction to the project Database Design Film Kategori FIELD TYPE KEY FIELD TYPE Id INTEGER PK Id INTEGER PK Name TEXT name TEXT created_at DATETIME created_at DATETIME Film_kategori FIELD TYPE KEY Id INTEGER PK Film_id INTEGER Kategori_id INTEGER KEY
  • 6. Example Data Kategori Film Id Name Id Name 1 Ketika Jomblo Bertasbih 1 Action 2 Petualangan si gundul 2 Horror 3 Transformer 3 Adventure 4 Sadako 4 Drama 5 3 Hati 2 Dunia 1 Cinta Film_Kategori Id 1 Film_id 1 Kategori_id 4 2 2 3 3 3 1 4 4 2 5 5 4
  • 7. Let’s Start a New Project  Click New in the toolbar. In the window that appears, open the Android folder, select Android Application Project, and click Next. Figure 1. The New Android App Project wizard in Eclipse.
  • 8. Creating Model Class for Tables  Create Class Film.java and Kategori.java in package model And create constructor, setter and getter
  • 9. Creating DatabaseHelper  Create Class DatabaseHelper.java in package helper  And create CRUD(Create, Read, Update, Delete) Operations
  • 10. MainActivity  In the below I just created sample Kategori and Film data and performed the all the operations by calling the methods which we prepared in DatabaseHelper class.
  • 11. Run App…. Check data in Database  I Check data in Database Sqlite with Sqlite Editor
  • 12. Source Code?  Check Source Code in My GitHub  https://github.com/dpapayas/SqliteMultipleTables