Home » Android » android – Break SQL query into parts for accessing content provider-Exceptionshub

android – Break SQL query into parts for accessing content provider-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

I have an SQL query from string and trying to access ContentProvider. The sql query looks like:

String query = "SELECT * FROM application_settings WHERE _id = ?";

I have to access content provider by gettting ContentResolver like:

context.getContentResolver().query()

but query method accepts:

Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder);

So is there some way I can split the string query into projection, selection, selectionArgs and sortOrder?

I do not wish to execute raw queries so I would prefer to have a solution for this with bind values.

How to&Answers: