Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7770397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:24:02+00:00 2026-06-01T16:24:02+00:00

Please some one tell me that how I can delete the same message that

  • 0

Please some one tell me that how I can delete the same message that I was captured on the onReceive method. Actualy, I wish that when a massage is received on onReceive method it was first use off and after use it delete but how i dont know so please help me in case.
Code that I am using also tag with this thread.

  @Override
    public void onReceive(Context context,final Intent intents){
    if (intents.getAction().equals(ConstantClass.SMS_RECEIVED)) {
    new Thread(){
    Context context;
    Thread Set(Context ctx){
    this.context=ctx;
    return this;
    }
    public void run(){
    try{
    Bundle bundle = intents.getExtras();            
    if (bundle != null) {
    Object[] pdus = (Object[]) bundle.get("pdus");
    SmsMessage[] messages = new SmsMessage[pdus.length];
    for (int i = 0; i < pdus.length; i++)
    messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
    String msg=null;
    String address = null;
    for (SmsMessage message : messages) {
    msg = message.getMessageBody();
    address = message.getOriginatingAddress();
    }
    dba.Open();
    int id = dba.getCordiId(address);
    int count = dba.getDeviceCount(ConstantClass.dbName[1]);
    if(count<=0){
    dba.InsertCurrentCoord(id,id);
    }else{
    Strsql = new String("UPDATE " + ConstantClass.dbName[1] + " SET " + DataBaseAdapter.Key_ReceiverCoord + " = " + 
    Integer.toString(id) + " WHERE " + DataBaseAdapter.Key_ID + " = ?");
    dba.UpdateQuery(Strsql, Integer.toString(id));
    }
    dba.Close();
    ////////////sending to SMSSync class//////////////
    MainThread th = new MainThread(sync,msg);
    try{
    th.thread.join();
    }catch(Exception e){
    Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
    if(msg.substring(3, 4).equals("2"))
    ConstantClass.isAuditrequestSend = true;
    }
    /*******after receiving the sms opening the Main Screen.*****************/
    Intent intent = new Intent(context,ZigbeeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
    abortBroadcast();
    /************Now deleting the SMS from the Inbox*********************/
    Uri uriSms = Uri.parse("content://sms"); 
    Cursor c = context.getContentResolver().query(uriSms, null,null,null,null);  
    int trId= c.getInt(0);
    int thread_id =c.getInt(1); 
    context.getContentResolver().delete(Uri.parse("content://sms/conversations/" + thread_id),null,null); 
    }catch(Exception e){
    dlg = new ExceptionDialog(context,"On Sms Receiver",e.getMessage());
    dlg.show();
    }
    }
    }.Set(context).start();
    }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:24:03+00:00Added an answer on June 1, 2026 at 4:24 pm

    Try this method and let me know what happens, just pass the context and number from where the message has came,

    Note:-

    This is used to delete complete Thread for a particular number

    private void removeMessage(Context context, String fromAddress) {
    
            Uri uriSMS = Uri.parse("content://sms/inbox");
            Cursor cursor = context.getContentResolver()
                                           .query(uriSMS, null, null, null, null);
            cursor.moveToFirst();
            if(cursor.getCount() > 0){
                int ThreadId = cursor.getInt(1);
                Log.d("Thread Id", ThreadId+" id - "+cursor.getInt(0));
                Log.d("contact number", cursor.getString(2));
                Log.d("column name", cursor.getColumnName(2));
    
                context.getContentResolver().delete(Uri.
                       parse("content://sms/conversations/"+ThreadId), "address=?", 
                                                         new String[]{fromAddress});
                Log.d("Message Thread Deleted", fromAddress);
            }
            cursor.close();
        }
    

    Also, call this method after a delay of Thread like,

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(2000);
                removeMessage(mContext, "From_number");
            } catch (InterruptedException e) {
                e.printStackTrace();
                 }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please can some one briefly tell me with example what does the means of
can some one please tell me, how can I write a awk program to
can someone please tell why , Great Microsoft that created C# language and now
Some one please tell me how to handle RunTimeExceptions in grails version1.1 .I have
Please can someone tell me the technique that would be used, for the following
Could you please tell me why I can't delete from collection records with ids
Can someone please tell me why this doesn't work? I'm trying to show and
Can someone please tell me how I can implement the following line of pseudo-code.
Can someone please tell me ehy in IE 6 div is not in center.
Can someone please tell me how to show all privileges/rules from a specific user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.