samedi 16 janvier 2016

How to join ContentProvider tables through rawQuery?

I want to make sql join through rawQuery.

For example the uri's are as follow:

Uri mmsPartUri = Uri.parse("content://mms/part"); 
Uri mmsInboxUri = Uri.parse("content://mms/inbox");


SQLiteDatabase db = //how to get it?

I imagine the query would look like similar to this:

Cursor cursor = db.rawQuery("SELECT mms.part.mid, mms.part.text, mms.inbox.m_id, mms.inbox.date FROM mms.part JOIN mms.inbox
             ON mms.part.mid = mms.inbox.m_id, null);

Is it possible? Then how? If not is there any other option to join tables, or do I have to use two Cursors and CursorJoiner to get similar result?

If join is not possible across different content providers, I'm curious if I can do any rawQueris like this:

Uri mmsPartUri = Uri.parse("content://mms/part");
SQLiteDatabase db = //how to get it?
Cursor cursor = db.rawQuery("SELECT mms.part.mid, mms.part.text,  FROM mms.part, null);

I saw this and this.

Aucun commentaire:

Enregistrer un commentaire