JaycePark
JaycePark

Reputation: 435

Can I use SQL for Android contacts database to execute complicated update?

Assume that I want to update dirty flags of some contacts linked to a group.

To do this,

  1. From 'data' table, records having the group ID should be queried.
  2. Should update using contact ID in the fetched records.

But if I can use SQL, it can be done with one SQL statement.

Is it possible?

Thanks in advance.

Upvotes: 0

Views: 52

Answers (1)

Ivan Bartsov
Ivan Bartsov

Reputation: 21036

No, I don't think so.

See, Android API doesn't let you access the SQLite database behind the contacts (although it is there) but rather abstracts data access by means of ContentProviders (And there's a good reason for that: giving developers access to the SQLite db would be way too insecure -- any app with proper permissions could e.g. drop the contact tables and thus cause major malfunctions of other apps)

It's not much more complex to run update statements on those though (well, apart from the fact that SQL statements are kind of broken down into methods and parameters), the ContentProvider class has .update() method for just that, the tricky part is the WHERE part of the call, you'll have to take a good look at the ContactsContract class.

Upvotes: 2

Related Questions