Ya...Just noticied that MmsSmsProvider didn't have a direct uri for
"canonical_addresses". But they have it for "canonical_addresses" item (
canonical-address/# ).

I suggest you to first query Thread's table to get all recipients_id and
then look into "canonical_addresses" item for the address. You might ends up
in making mutiple queries to "canonical_addresses" item uri.

On Thu, Feb 17, 2011 at 4:11 PM, Madhavi <[email protected]> wrote:

> Thanks for the early reply.
> The idea is good to check first in "canonical_addresses" table but i
> have not found Uri exposed to get canonical table _id for the given
> address.
> We have the only Uri exposed to fetch address for the given _id. Do
> you have any idea how to get _id from "canonical_addresses" table for
> the given address.
> Following is the refered link for uris
>
> http://www.netmite.com/android/mydroid/packages/providers/TelephonyProvider/src/com/android/providers/telephony/MmsSmsProvider.java
>
> Thanks,
> Madhavi
>
> On Feb 16, 6:54 pm, sukumar bhashyam <[email protected]>
> wrote:
> > hi ,
> >
> > Uri "content://mms-sms" doesn't point to any table in mmssms db, Its just
> a
> > base uri.
> >
> > To check for address, I guess, you need to run below steps...
> >
> >  --> First query "canonical_addresses" table and get the _id, If query
> has 0
> > count then address is not found.
> >  --> If not, then look for _id in threads table ( Threads.ContentUri)
> where
> > recipients_id is equal to id received in step 1.
> >
> >
> >
> > On Wed, Feb 16, 2011 at 5:22 PM, Madhavi <[email protected]>
> wrote:
> > > Hi All,
> >
> > > In my application I have tried to get thread id using following code.
> >
> > > public static long getThreadIdFromAddress(ContentResolver resolver,
> > >                        String address)
> > >        {
> > >                if (address == null)
> > >                {
> > >                        return 0;
> > >                }
> > >                // Content URIs for SMS app, these may change in future
> SDK
> > >                Uri threadIdContentUri = Uri.withAppendedPath(Uri
> > >                                .parse("content://mms-sms/"),
> "threadID");
> > >                String smsId = "_id";
> > >                String threadRecipientQuery = "recipient";
> > >                Uri.Builder uriBuilder = threadIdContentUri.buildUpon();
> > >                uriBuilder.appendQueryParameter(threadRecipientQuery,
> > > address);
> > >                long threadId = 0;
> > >                Cursor cursor = resolver.query(uriBuilder.build(),
> > >                                new String[] { smsId }, null, null,
> null);
> > >                if (cursor != null)
> > >                {
> > >                        try
> > >                        {
> > >                                if (cursor.getCount() > 0)
> > >                                {
> > >                                        cursor.moveToFirst();
> > >                                        for (int i = 0; i <
> > > cursor.getCount(); i++)
> > >                                        {
> > >                                                threadId =
> > > cursor.getLong(i);
> > >                                        }
> > >                                }
> > >                        }
> > >                        finally
> > >                        {
> > >                                cursor.close();
> > >                                cursor = null;
> > >                        }
> > >                }
> > >                return threadId;
> > >        }
> >
> > > This is creating new thread id if its not exits in the sms-mms
> > > database.
> >
> > > I have refered Threads class code from
> > >http://hi-android.info/src/android/provider/Telephony.java.html.
> > > This clearly indicates that new thread will get generated if it does
> > > not exists.
> >
> > > In our application we are trying to get all conversations/messages for
> > > the contacts used. We are fetching conversations/message data on the
> > > basis of threadId which we are getting from above method call. Now
> > > even if a particular contact does not have any message thread
> > > available in message store, an empty message is getting generated. And
> > > in native message application the newly generated message thread with
> > > subject line as "(No subject)" is getting displayed.
> >
> > > I want to avoid this. If there is no message for a particular contact
> > > I want to get thread id as "null" or "0". Do you know how can I
> > > achieve this?
> >
> > > Or do you have any other suggetion to avoid above mentioned scenario?
> >
> > > Note: The device I have used is HTC-Nexus One. And the android version
> > > used is 2.2.1.
> >
> > > Thanks,
> > > Madhavi
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en- Hide quoted
> text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to