Content Provider – Part 2 – create and query

Content Provider – Part 2 – create and query

You can read part 1 here. To create a Content Provider you need to: extend the ContentProvider class implement the lifecycle methods implement the data lookup methods implement the modification methods create a Content Provider identification specify Content Provider’s visibility to other apps Content Provider is responsible to connect to the database and perform all the database interactions. The methods are similar to the SQLite API. Add a Content Provider to your app Right-click the package name, then click New, Other and then Content Provider. You will see the following…

Content Provider – Part 2 – create and query Read More

Android – SQLiteDatabase.query

Android – SQLiteDatabase.query

query method gives you access to the data of a SQLiteDatabase. You specify what you want to return from a table, it is like SQL select, and it returns back a Cursor. You can specify table name, columns, selection, groupBy, having, orderBy and limit. The syntax is: Cursor provides access to the query results and allows us to go through the results row by row. The cursor maintains a position and we should position it to a specific row, also in the beginning using moveToNext. Some other methods are: moveToPrevious,…

Android – SQLiteDatabase.query Read More