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

-- 
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