SlideShare a Scribd company logo
Software Engineering Large Practical

Working with databases in Android

                  Stephen Gilmore

     School of Informatics, University of Edinburgh


               October 17th, 2012




             Stephen Gilmore   Software Engineering Large Practical
A database example




   In this lecture we will look at an example Android application
   which creates a database of TODO notes, with reminders of things
   which need to be done, and descriptions of these.

   The application is due to Lars Vogel (http://www.vogella.com).




                        Stephen Gilmore   Software Engineering Large Practical
Lars Vogel example: TODOs




                 Stephen Gilmore   Software Engineering Large Practical
A database example




                     Stephen Gilmore   Software Engineering Large Practical
TodoDatabaseAdapter




                 Stephen Gilmore   Software Engineering Large Practical
TodoDatabaseHelper (onCreate())




                 Stephen Gilmore   Software Engineering Large Practical
TodoDatabaseHelper (onUpgrade())




                 Stephen Gilmore   Software Engineering Large Practical
TodoDatabaseAdapter (open(), close())




                 Stephen Gilmore   Software Engineering Large Practical
The create, update, and delete methods




                   Stephen Gilmore   Software Engineering Large Practical
The insert() method




                Stephen Gilmore   Software Engineering Large Practical
The update() method




                Stephen Gilmore   Software Engineering Large Practical
The delete() method




                Stephen Gilmore   Software Engineering Large Practical
Fetch data




             Stephen Gilmore   Software Engineering Large Practical
Create content values




                   Stephen Gilmore   Software Engineering Large Practical
Resources




            Stephen Gilmore   Software Engineering Large Practical
Running the application




   When we run the application we are able to create a TODO note,
   and set its category to Urgent or Reminder.




                       Stephen Gilmore   Software Engineering Large Practical
Running the TODOs application




                  Stephen Gilmore   Software Engineering Large Practical
Editing a TODO item




                 Stephen Gilmore   Software Engineering Large Practical
Setting category to “Urgent”




                   Stephen Gilmore   Software Engineering Large Practical
TODOs application code




  We look at the application code to see how the Java code interacts
  with the XML layout and see how the database state is managed.




                       Stephen Gilmore   Software Engineering Large Practical
TodoDetails (imports)




.14.20.png




                      Stephen Gilmore   Software Engineering Large Practical
TodoDetails (onCreate)




.14.31.png




                      Stephen Gilmore   Software Engineering Large Practical
Graphical layout of todo edit.xml




.32.52.png


                     Stephen Gilmore   Software Engineering Large Practical
Text of todo edit.xml




.32.48.png


                    Stephen Gilmore   Software Engineering Large Practical
Outline of todo edit.xml




.32.48.png


                     Stephen Gilmore   Software Engineering Large Practical
TodoDetails (populateFields)




.14.38.png




                      Stephen Gilmore   Software Engineering Large Practical
Save state, onPause, onResume




.14.48.png




                     Stephen Gilmore   Software Engineering Large Practical
Save state




.14.56.png




                Stephen Gilmore   Software Engineering Large Practical
TodosOverview (onCreate)




.15.04.png




                     Stephen Gilmore   Software Engineering Large Practical
Options menu, item selected




.15.10.png




                      Stephen Gilmore   Software Engineering Large Practical
Options item selected




.15.22.png




                       Stephen Gilmore   Software Engineering Large Practical
Accessing the insert menu




.16.16.png

                      Stephen Gilmore   Software Engineering Large Practical
Inspecting the database




   During development we might have bugs in our code which cause
   problems with the database. In this case we would like to be able
   to see the content of the database and check that it is as we
   expect. We can use the Dalvik Debug Monitor Server (DDMS) to
   do this and we can also inspect the database using other tools for
   processing SQLlite databases.




                         Stephen Gilmore   Software Engineering Large Practical
Dalvik Debug Monitor Server (DDMS)




.21.38.png




                     Stephen Gilmore   Software Engineering Large Practical
File explorer in DDMS




                   Stephen Gilmore   Software Engineering Large Practical
/data/data/de.vogella.android.todos/...




                    Stephen Gilmore   Software Engineering Large Practical
Pulling a file from the device




                    Stephen Gilmore   Software Engineering Large Practical
Pulling a file from the device




                    Stephen Gilmore   Software Engineering Large Practical
Get the device file




                     Stephen Gilmore   Software Engineering Large Practical
Inspecting the file with sqlite3




                   Stephen Gilmore   Software Engineering Large Practical
Inspecting the file with sqlite3 on DiCE




                   Stephen Gilmore   Software Engineering Large Practical
Other tools for inspecting the database

   Numerous browsers exist for SQLite databases.
       The CellObject SQLite & XML Browser is an Eclipse
       plug-in tool built on top of Dalvik Debug Monitor Server
       (DDMS), intended for Android application developers. It is
       available from http://cellobject.net/
       SQLite Manager is an add-on for Firefox which allows users
       to browse SQLite databases using the Firefox browser. It is
       available from https://addons.mozilla.org/en-US/
       firefox/addon/sqlite-manager/
       SQLite Database Browser allows users to create, design and
       edit database files compatible with SQLite using a familiar
       spreadsheet-like interface. It is available from
       http://sqlitebrowser.sourceforge.net/


                        Stephen Gilmore   Software Engineering Large Practical
Using LogCat




  As usual, the effect of Java exceptions and other problems will
  appear in the LogCat view.




                       Stephen Gilmore   Software Engineering Large Practical
Debugs and errors displayed in LogCat




.22.45.png




                      Stephen Gilmore   Software Engineering Large Practical
Can filter messages displayed in LogCat




.34.51.png




                      Stephen Gilmore   Software Engineering Large Practical
Can use view menu to export messages




.40.30.png




                     Stephen Gilmore   Software Engineering Large Practical

More Related Content

PDF
SELP: Debugging, AVDs and Manifests
PDF
Beginning Android Development
PDF
Test Driven Design - GDG DevFest Istanbul 2016
PDF
Testing Android apps with Robotium
PDF
Arrays in Objective-C
PPT
Android overview
PPTX
Hacker Halted 2014 - Reverse Engineering the Android OS
PPT
My Final year project on Android app development
SELP: Debugging, AVDs and Manifests
Beginning Android Development
Test Driven Design - GDG DevFest Istanbul 2016
Testing Android apps with Robotium
Arrays in Objective-C
Android overview
Hacker Halted 2014 - Reverse Engineering the Android OS
My Final year project on Android app development

Viewers also liked (9)

PPT
Steelcon 2015 Reverse-Engineering Obfuscated Android Applications
PPTX
Toll app - Android project
PDF
UseCase is a DIALOG---NOT a PROCESS
DOC
Activity diagram railway reservation system
PPTX
Payroll and attendance system
DOC
Usecase diagram railway reservation system
PPTX
Ziilion E245 final presentation
PPT
Android seminar-presentation
PPT
Software Engineering ppt
Steelcon 2015 Reverse-Engineering Obfuscated Android Applications
Toll app - Android project
UseCase is a DIALOG---NOT a PROCESS
Activity diagram railway reservation system
Payroll and attendance system
Usecase diagram railway reservation system
Ziilion E245 final presentation
Android seminar-presentation
Software Engineering ppt
Ad

Similar to Working with databases in Android (20)

PDF
Feedback on Part 1 of the Software Engineering Large Practical
PDF
Common Java problems when developing with Android
PDF
Software Engineering Large Practical coursework
DOCX
Notepad tutorial
PDF
Android development beyond the basics
PDF
Database Refactoring
PPTX
Session 3 beccse
PDF
Lab 4) working with databases
PPTX
Android village @nullcon 2012
PPT
What is Software Engineering?
PDF
Lecture 1 - Introduction of Software engineering .pdf
PDF
Creating and working with databases in Android
PPTX
Big(ger) Data in Software Engineering
PDF
PDF
SSBSE 2012 Keynote
PDF
Data structures and_algorithms_in_java
PDF
Big Ball of Mud: Software Maintenance Nightmares
DOC
City search documentation
PDF
Flow based-1994
PDF
City search documentation
Feedback on Part 1 of the Software Engineering Large Practical
Common Java problems when developing with Android
Software Engineering Large Practical coursework
Notepad tutorial
Android development beyond the basics
Database Refactoring
Session 3 beccse
Lab 4) working with databases
Android village @nullcon 2012
What is Software Engineering?
Lecture 1 - Introduction of Software engineering .pdf
Creating and working with databases in Android
Big(ger) Data in Software Engineering
SSBSE 2012 Keynote
Data structures and_algorithms_in_java
Big Ball of Mud: Software Maintenance Nightmares
City search documentation
Flow based-1994
City search documentation
Ad

More from Stephen Gilmore (14)

PDF
Feedback on Part 1 of the CSLP
PDF
More Stochastic Simulation Examples
PDF
Quick quiz on Objective-C
PDF
Getting started with Xcode
PDF
Crash Course in Objective-C
PDF
The Stochastic Simulation Algorithm
PDF
Computer Science Large Practical coursework
PDF
Introduction to the CSLP and the SELP
PDF
Fixing errors in Android Java applications
PDF
Feedback on Part 1 of the Individual Practical
PDF
Continuing Android development
PDF
Project management for the individual practical
PDF
Beginning Android development
PDF
CS/SE Individual practical - DDMS and AVD
Feedback on Part 1 of the CSLP
More Stochastic Simulation Examples
Quick quiz on Objective-C
Getting started with Xcode
Crash Course in Objective-C
The Stochastic Simulation Algorithm
Computer Science Large Practical coursework
Introduction to the CSLP and the SELP
Fixing errors in Android Java applications
Feedback on Part 1 of the Individual Practical
Continuing Android development
Project management for the individual practical
Beginning Android development
CS/SE Individual practical - DDMS and AVD

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
GDM (1) (1).pptx small presentation for students
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Pharma ospi slides which help in ospi learning
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
2.FourierTransform-ShortQuestionswithAnswers.pdf
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
RMMM.pdf make it easy to upload and study
VCE English Exam - Section C Student Revision Booklet
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
GDM (1) (1).pptx small presentation for students
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Final Presentation General Medicine 03-08-2024.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Cell Types and Its function , kingdom of life
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE

Working with databases in Android

  • 1. Software Engineering Large Practical Working with databases in Android Stephen Gilmore School of Informatics, University of Edinburgh October 17th, 2012 Stephen Gilmore Software Engineering Large Practical
  • 2. A database example In this lecture we will look at an example Android application which creates a database of TODO notes, with reminders of things which need to be done, and descriptions of these. The application is due to Lars Vogel (http://www.vogella.com). Stephen Gilmore Software Engineering Large Practical
  • 3. Lars Vogel example: TODOs Stephen Gilmore Software Engineering Large Practical
  • 4. A database example Stephen Gilmore Software Engineering Large Practical
  • 5. TodoDatabaseAdapter Stephen Gilmore Software Engineering Large Practical
  • 6. TodoDatabaseHelper (onCreate()) Stephen Gilmore Software Engineering Large Practical
  • 7. TodoDatabaseHelper (onUpgrade()) Stephen Gilmore Software Engineering Large Practical
  • 8. TodoDatabaseAdapter (open(), close()) Stephen Gilmore Software Engineering Large Practical
  • 9. The create, update, and delete methods Stephen Gilmore Software Engineering Large Practical
  • 10. The insert() method Stephen Gilmore Software Engineering Large Practical
  • 11. The update() method Stephen Gilmore Software Engineering Large Practical
  • 12. The delete() method Stephen Gilmore Software Engineering Large Practical
  • 13. Fetch data Stephen Gilmore Software Engineering Large Practical
  • 14. Create content values Stephen Gilmore Software Engineering Large Practical
  • 15. Resources Stephen Gilmore Software Engineering Large Practical
  • 16. Running the application When we run the application we are able to create a TODO note, and set its category to Urgent or Reminder. Stephen Gilmore Software Engineering Large Practical
  • 17. Running the TODOs application Stephen Gilmore Software Engineering Large Practical
  • 18. Editing a TODO item Stephen Gilmore Software Engineering Large Practical
  • 19. Setting category to “Urgent” Stephen Gilmore Software Engineering Large Practical
  • 20. TODOs application code We look at the application code to see how the Java code interacts with the XML layout and see how the database state is managed. Stephen Gilmore Software Engineering Large Practical
  • 21. TodoDetails (imports) .14.20.png Stephen Gilmore Software Engineering Large Practical
  • 22. TodoDetails (onCreate) .14.31.png Stephen Gilmore Software Engineering Large Practical
  • 23. Graphical layout of todo edit.xml .32.52.png Stephen Gilmore Software Engineering Large Practical
  • 24. Text of todo edit.xml .32.48.png Stephen Gilmore Software Engineering Large Practical
  • 25. Outline of todo edit.xml .32.48.png Stephen Gilmore Software Engineering Large Practical
  • 26. TodoDetails (populateFields) .14.38.png Stephen Gilmore Software Engineering Large Practical
  • 27. Save state, onPause, onResume .14.48.png Stephen Gilmore Software Engineering Large Practical
  • 28. Save state .14.56.png Stephen Gilmore Software Engineering Large Practical
  • 29. TodosOverview (onCreate) .15.04.png Stephen Gilmore Software Engineering Large Practical
  • 30. Options menu, item selected .15.10.png Stephen Gilmore Software Engineering Large Practical
  • 31. Options item selected .15.22.png Stephen Gilmore Software Engineering Large Practical
  • 32. Accessing the insert menu .16.16.png Stephen Gilmore Software Engineering Large Practical
  • 33. Inspecting the database During development we might have bugs in our code which cause problems with the database. In this case we would like to be able to see the content of the database and check that it is as we expect. We can use the Dalvik Debug Monitor Server (DDMS) to do this and we can also inspect the database using other tools for processing SQLlite databases. Stephen Gilmore Software Engineering Large Practical
  • 34. Dalvik Debug Monitor Server (DDMS) .21.38.png Stephen Gilmore Software Engineering Large Practical
  • 35. File explorer in DDMS Stephen Gilmore Software Engineering Large Practical
  • 36. /data/data/de.vogella.android.todos/... Stephen Gilmore Software Engineering Large Practical
  • 37. Pulling a file from the device Stephen Gilmore Software Engineering Large Practical
  • 38. Pulling a file from the device Stephen Gilmore Software Engineering Large Practical
  • 39. Get the device file Stephen Gilmore Software Engineering Large Practical
  • 40. Inspecting the file with sqlite3 Stephen Gilmore Software Engineering Large Practical
  • 41. Inspecting the file with sqlite3 on DiCE Stephen Gilmore Software Engineering Large Practical
  • 42. Other tools for inspecting the database Numerous browsers exist for SQLite databases. The CellObject SQLite & XML Browser is an Eclipse plug-in tool built on top of Dalvik Debug Monitor Server (DDMS), intended for Android application developers. It is available from http://cellobject.net/ SQLite Manager is an add-on for Firefox which allows users to browse SQLite databases using the Firefox browser. It is available from https://addons.mozilla.org/en-US/ firefox/addon/sqlite-manager/ SQLite Database Browser allows users to create, design and edit database files compatible with SQLite using a familiar spreadsheet-like interface. It is available from http://sqlitebrowser.sourceforge.net/ Stephen Gilmore Software Engineering Large Practical
  • 43. Using LogCat As usual, the effect of Java exceptions and other problems will appear in the LogCat view. Stephen Gilmore Software Engineering Large Practical
  • 44. Debugs and errors displayed in LogCat .22.45.png Stephen Gilmore Software Engineering Large Practical
  • 45. Can filter messages displayed in LogCat .34.51.png Stephen Gilmore Software Engineering Large Practical
  • 46. Can use view menu to export messages .40.30.png Stephen Gilmore Software Engineering Large Practical