I have an Android app with a database called "myTestDB" with a table called "list_items". I want to use the Cursor getContentResolver().query() method to get a cursor to add to a SimpleCursorAdapter. The first argument of the query() method is a URI and I'm not sure what the URI should look like.
You do not use getContentResolver()
to access a SQLite database directly. You use getContentResolver()
when working with content providers. You call query()
on a SQLiteDatabase
object to get a Cursor
for use with SimpleCursorAdapter
.
A database doesn't have a Uri (other than the file where it's located). Data managed through a content provider has one. If you want to use the content resolver to perform a query, you need to write a content provider first.
If you don't want to do that, simply use SQLiteDatabase's query
function - it returns a Cursor that you can pass to the SimpleCursorAdapter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With