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 6795133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:18:23+00:00 2026-05-26T18:18:23+00:00

I’ve created one application that is inserting messages programmatically. In that application running successfully.

  • 0

I’ve created one application that is inserting messages programmatically. In that application running successfully.

It’ll inserted the message whatever given in record. After, you’ll not able to see your inserted message in your messages where device or emulator. Check out that.

I don’t know why this is happening. You’ll able to see your message when, you stopped the messaging in your task manager. After, you can see your inserted message.

What am missing in that code.

Any help appreciated? Best Regards – SPK

The code

Activity:

public class SMS extends Activity 
{
    Button btnSendSMS;
    EditText txtPhoneNo;
    EditText txtMessage;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
        btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
        final insert i = new insert(this);
        btnSendSMS.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v) 
            {
                i.method_inser();
                Toast.makeText(getApplicationContext(), "Inserted", Toast.LENGTH_SHORT).show();             
            }
        });
    } 
}

Class insert:

public class insert
{
    Context ctx,context;
    ContentResolver cr;

    public insert(Context context)
    {
        this.context = context;
        cr = context.getContentResolver();
    }
    public void method_inser()
    {
        Uri smsuri = Uri.parse("content://sms/");
        ContentValues iv = new ContentValues();
        String[] final_result = {"1","1","15555215556","3","1320753694842","0","1","-1","1","0","null","Gingerbread","null","0","0","1"};
        iv.put("_id", final_result[0]);
        iv.put("thread_id", final_result[1]);
        iv.put("address", final_result[2]);
        iv.put("person", final_result[3]);
        iv.put("date", final_result[4]);
        iv.put("protocol", final_result[5]);
        iv.put("read", final_result[6]);
        iv.put("status", final_result[7]);
        iv.put("type", final_result[8]);
        iv.put("reply_path_present", final_result[9]);
        iv.put("subject", final_result[10]);
        iv.put("body", final_result[11]);
        iv.put("service_center", final_result[12]);
        iv.put("locked", final_result[13]);
        iv.put("error_code", final_result[14]);
        iv.put("seen", final_result[15]);
        cr.insert(smsuri, iv);
    }
}
  • 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-05-26T18:18:24+00:00Added an answer on May 26, 2026 at 6:18 pm

    _id and thread_id are primary key and you are trying to insert fix value all the time so it will work only once

    Also remove two fields error_code and seen because there are no any column in a sms table

    Also you have to add following permissions in manifest

    <uses-permission android:name="android.permission.SEND_SMS"/>
    <uses-permission android:name="android.permission.WRITE_SMS"/>
    <uses-permission android:name="android.permission.READ_SMS">
    

    After inserting new message in inbox you have to notify changed using content resolver

    Use this code to notify change

    Uri uri = cr.insert(smsuri, iv);
    cr.notifyChange(uri, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am currently running into a problem where an element is coming back from
I'm making a simple page using Google Maps API 3. My first. One marker
I'm trying to create an if statement in PHP that prevents a single post
I need a function that will clean a strings' special characters. I do NOT
Basically, what I'm trying to create is a page of div tags, each has

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.