How To Insert Data Into A Database Table In Android Sdk


show more Inserting data into a database table provides you with in-depth training on Developer. Taught by David Gassner as part of the Android SDK: Local Data Storage show less
please wait ...

Inserting data into a database table

Once you've created your Open Helper and Data Source classes, you can start adding code to manage your database, including code to insert, update, and delete rows, and to read data from the database tables. I'll start with inserting data in this project. I've opened the class ToursDataSource.java, and I'll add a new method to the class that I'll name create. I'll place this at the end of the existing methods. It will be public so that it can be called from anywhere in the application and it will return an instance of my tour class which is in my model package.

I'll make sure to add the import statement. The name of the method is create, and it will receive a single argument, also data type as Tour and named tour. In order to pass data into the database, you could execute an explicit SQL statement, but then it's up to you to handle all sorts of coding, including escaping special characters, using single quotes where you shouldn't be using double quotes, and so on...

Inserting data into a database table
Video duration: 10m 29s 3h 41m Intermediate

Viewers:

Inserting data into a database table provides you with in-depth training on Developer. Taught by David Gassner as part of the Android SDK: Local Data Storage

Subject:
Developer
Software:
Android Java
Author:
please wait ...