Chapter 12. Cursors and Asynctasks: Connecting to Databases
So how do you connect your app to a SQLite database?
So far you’ve seen how to create a SQLite database using a SQLite helper. The next step is to get your activities to access it. In this chapter, you’ll find out how to use cursors to get data from the database, how to navigate cursors, and how to get data from them. You’ll then find out how to use cursor adapters to connect them to list views. Finally, you’ll see how writing efficient multithreaded code with AsyncTasks will keep your app speedy.
The story so far...
In Chapter 11, you saw how to write a SQLite helper to create a database, and how to add tables and prepopulate them with data. You also saw how to make the SQLite helper deal with database upgrades so that you can change the structure of the database and manipulate the data it contains by upgrading it.
In this chapter, we’re going to show you how to get your activities to interact with the database so that your user can read from and write to the database using your app.
Here’s the current state of our Starbuzz app:
We’re going to change the Starbuzz app so that it uses the Starbuzz SQLite database instead of the Java ...