How to Make Android Apps 20

Get the Code Here :

SQLite Tutorial :

In this part of my Android tutorial we will cover using SQLite. We’ll create the database, verify its creation, add data, delete data, display data and delete the database. We’ll also explore Cursors and more.

I structured the app so that it is both very easy to understand and so you’ll be able to cut and paste out the features you need for your apps. I also have an SQLite tutorial that you’ll find very useful.






48 responses to “How to Make Android Apps 20”

  1. Zeeshan Ali Avatar

    Hats off to you sir!! You make everything look easy!

  2. Bokchee 88 Avatar

    How do delete an contact when not knowing the ID of the row?

  3. hong lien lor Avatar

    I was just wondering if you can do a check for valid id for the delete button. What I mean by that is that, if an id doesn't exist, a toast would pop out and said that, id does not exist, but if an id exist, it just delete the id. I was also wondering if you can do an update, like if you want to change a name of an exist contact, to a different name.

  4. Darkbdlz Avatar

    Can you make one class that has the databse and other classes that access the class with the database

  5. kevin narul Avatar

    hello derek.. im using my android phone as my simulator as my virtual simulator is not working(BIOS problem).. i already follow thoroughly ur tutorial. but i seem unable to create the database.. i checked the Android Monitor, i cant seem to expand the data file from it.. how can i solve this problem?

  6. a curious vegan Avatar

    What about SQL injections for your INSERT statements ?

  7. Kamil Bęben Avatar

    If you are trying to open database from /assets/ folder and it turn's out that you can't – then you've got to copy that database from assets folder to data/data/com.yourdomain.appname/databases (NOT Manually, google 'loading SQLite database from assets'. I didn't knew that and it took me a couple of hours, so maybe it'll save someone some time.

  8. Tyler Caudell Avatar

    Great video, love your work. I'm having trouble figuring something out though. How would you store data of arbitrary length to a database? The data I'm particularly working with can be formatted to a simple JSON string array and stored as that, but it's inefficient (probably?) to constantly re-create the JSON to save new data or different data. I know there's such a thing called a BLOB. How would you go about doing that? Would you use a BLOB?

  9. Vamsi Krishna Avatar

    Thank you, Derek. Your videos are excellent.
    I have problems executing the code in the latest version of Android Studio. What changes should I make in order to make them run successfully.

  10. gabriel brito Avatar

    Hey derek thanks for the video helped me a lot.
    But i've got other problem.
    Now i want to make a big database 6000 registers, and i don't the user to
    edit it.
    Should i use sqlite, or find another way?

  11. Tony Mione Avatar

    First of all, excellent series. Thanks for creating these!
    I have a question on using a full up SQL implementation with Android. Is there a way to use Mysql on a backend server from an Android application? Does this involve installing a JDBC Connector library into Android Studio? I'd like to reuse some code as-is, if possible. Otherwise, I'd have to develop the equivalent DB code using SQLite to plug into the Android version of an app I am developing.

  12. Moshe Ventura Avatar

    Great tutorial, as allways!
    Is there any more-advanced tutorial about offline sync with SQLite?


  13. andkonst Avatar

    Is that for a local database on your PC?
    I guess it is not working if you need a remote database online using a server.Right?

  14. Sanket Shah Avatar

    Wish we had such cool stuff in college syllabus.
    You are the best teacher I've ever learnt from.
    From all the stuff on Android out there on youtube,this is undoubtedly the best.

  15. The_B&K_Life Avatar

    Hi Derek, thank you so much for all of your videos you are helping me learn a lot of coding, I even have my first app on the market now, but I am still very new, and I do not understand how to make a leader board or the components needed to make one. I have looked all over youtube and the google developers website, and have had no luck. Do you have a video explaining it? If not can you make one soon? Thank you!

  16. Sindorai Avatar

    So this is a late question but, lets say I have a string array and that array displays its current position as a textview- then theres a button that would send whatever the textview currently displays (I.E the current position in the array) to a database how would you link that button to the database and then display that stored info somewhere else?

  17. Suzan Maka Avatar

    when i click on create data base, i get the message "database missing", why?

  18. Jay Ryan Avatar

    +Derek Banas can you recommend the best way to include a pre-filled sqlite database with an app?  I have read that SQLite-Asset-Helper is the best way to go, I just want more opinions.  I have a lot of data that will be included in the database and i don't want to have to fill it as the tables are created the first time.  Thanks.

  19. hasbi dino Avatar

    so as far as i understand sqlite & this tutorial only saves data inside your mobile device? the actualy sqlite inside your computer's wont be created/updated, am i right?

  20. Calvin scott Avatar

    Derek great video one question: what would you change to read it from a pre made sql file and where would that file go

  21. Jake5762 Avatar

    Great video, helped me out a lot, Just wondering how would you pass the content of the database too and from different pages/activities? I tried getAddScreenIntent.putExtra but the other activities just don't recognise the database

  22. Yongyi Xu Avatar

    Thank you so much for all these android tutorials, they helped me out a lot. For this tutorial, I have followed your codes exactly however, when I ran the codes in my device, it cannot create database. Whenever I clicked on "Create Database" button, I kept on getting the toast message telling me that the database is missing. Was there anything I missed such as updating AndroidManifest.xml?

  23. Travis Clarke Avatar

    I can't thank you enough for the insightful tutorials. My skills have greatly improved since first seeing your videos. 

  24. Liégele Cabral Avatar

    Hi Derek, great video! Congratulations!

  25. David Benjamin Avatar

    Awesome! I think I may be on my way! GREAT! great flow, demonstration man everything. I'm a newbie but fall asleep with all the unnecessary info that people normally put in their tuts. Man I'm loving this! I'm a follower maaaaaaaaan!

  26. David workstv Avatar

    +Derek Banas how do i make an app that works with  google map API

  27. TRU Avatar

    +Derek Banas 
    Derek love the tuts. Question: is it possible to create an Android app using an existing websites database? Or will the mobile app need to have access to its on DB. Even further how can the 2 coincide if the DBs are separate. The best example I can use if FB and FB Apps or any popular social network. Post are stored in the Networks DB via an app and vice versa information is puled from the Websites DB and displayed on the app. I know the mobile apps use the Social Networks APIs but for a much smaller self made website…say a restaurant reservation and ordering system. Can 1 DB be used for both the mobile and the website?

  28. Eren Emrah Avatar

    Hello Derek, I wrote an updateContact function but it gives error can you find why is that?

     public void updateContact(View view) {
            //Get the contact name and email entered
            String contactName = nameEditText.getText().toString();
            String contactEmail = emailEditText.getText().toString();
            String id = idEditText.getText().toString();

            //add them into db
            contactsDB.execSQL("UPDATE contacts SET (name ='" + contactName + "', email ='" + contactEmail + "' WHERE id  =" + id + ");");
            Toast.makeText(this, "Contacts update Successfully", Toast.LENGTH_SHORT).show();

    logcatERROR is,
    Caused by: android.database.sqlite.SQLiteException: near "(": syntax error (code 1): , while compiling: UPDATE contacts SET (name =' nameupdated', email ='mailupdated' WHERE id  ='4');

  29. Brody Mason Avatar

    I have watched so many of your videos, About time I say "Well Hello!" back to you. Thank you so much for all the time, energy and effort you put into your videos and education. It has helped me tremendously. Over and over again, new topic to new topic, I enjoy learning from you. Keep up the good work!!

  30. ferejo Avatar

    Derek Banas can you do a TUTORIAL on how to make a java screen recorder? 

  31. soyboy Avatar

    Food for thought. Have you ever covered Jquery Mobile and using it to make web apps? and have you thought about doing an advance database section with pl/sql? Just wondering and HAPPY NEW YEARS! Always love your tuts!

  32. Icaro Pinho Avatar

    What if i wanted to make like a todo app, when user A logs in, he sees only his tasks, when user B logs in he sees only his tasks…  I should handle this with sql statements or java code?

  33. David Cruz Avatar

    Thanks again +Derek Banas … as usual, great video. Quick question, have you worked with RecyclerView and Cursors? Any plans to show how to make it work?

  34. Angelina Jolie Avatar

    Hi Derek ! Happy New Year
    Logic Doubt:
     // Check if the database exists
     if (!database.exists()) {
                    Toast.makeText(this, "Database Created", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(this, "Database Missing", Toast.LENGTH_SHORT).show();
     if the database doesn`t exist it is created and else if it exists wouldn`t the message be "Open the Database"?
    Thanks In Advance !

  35. John Karan Avatar

    Can your please upload a video showing how to use ViewPager for Screen Slides, Tabs with animations please.

  36. Marvelous Marv Avatar

    Very nice video. Thanks.

  37. iiCapitaine Avatar

    Hey Derek, thanks so much for your effort and altruism. I was hoping in what sequence should I watch your video playlists to ultimately understand what you're doing in Android Studios?
    Should I start with your java tutorial videos?
    Thanks for any suggestions!!

  38. ivopalchev Avatar

    Happy new year Derek, Great Tutorial.

  39. Techinbits Avatar

    Doesn't the concattenation of the strings (username etc) mean its dangerous for sql injection. Since we can just past a ; and cause a show * from users? Is there something as prepared statements? Where we just fill in parameters, causing the DB to compile both parts seperately? Or does this methode ensure sql injection is impossible?

  40. FiddiTwo Avatar

    very generous man .. thank you as always

  41. Erondeb Prado Avatar

    Happy new year #DerekBanas amazing gift to the fellow developers

  42. Smith 29 Avatar

    Any buzzing coders who could make an app for me? It shouldn't be too hard.

  43. BlownBones Avatar

    Derek, Have you ever done an application ? If yes, is it public ? And if not, why ?

  44. Antik Lee Avatar

    Thank you for the new year gift!
    Guten Rutsch ins 2015!!!

  45. Man HOOD Avatar

    How can we create a server based database ?

  46. Paul Dumitru Avatar

    Thank you for the hard work . Happy New Year Derek !

Leave a Reply

Your email address will not be published. Required fields are marked *