how to send sms to contact saved in database through an android app?
<p>i m developing an app which take message as input and sends it to the predefined numbers     stored in data base ! know the problem is i am inserting numbers in database when the app is loaded in <strong>oncreate()</strong> method  every time i send message at first if it send message to 4 number the on secnd attempt it'll send sms to 8 numbers and tired to move my data insertion code so that it will only insert data once not at every load but its not working please can any one helppp thankss !!</p>

<pre><code> btnSendSMS.setOnClickListener(new View.OnClickListener() 
    {
        public void onClick(View v) 
        {  
            //loop++;

                 db.open();
                 //loop++;
                  long id;


                  id = db.insertTitle(
                            "5556");  
                    id = db.insertTitle(
                            "5556");  

                    id = db.insertTitle(
                            "5556");  

                    id = db.insertTitle(
                            "5556");  

                 db.close();


             message = txtMessage.getText().toString();                 
            if ( message.length()&gt;0 &amp;&amp; message.length()&lt;200)                
            {
                 db.open(); 
                 Cursor c = db.getAllTitles();
                 if (c.moveToFirst())
                 { 


                     String phoneNo; 

                     do { phoneNo=c.getString(1) ;  
                        sendSMS(phoneNo,message);    
                      count++;
                        // db.DisplayTitle(c);
                        Toast.makeText(DatabaseSmsActivity.this,"sms no : "+count,Toast.LENGTH_LONG).show(); 

                     } while (c.moveToNext());
                 }
                 db.close();
                // Toast.makeText(DatabaseSmsActivity.this,"Total SMS sent : "+count,Toast.LENGTH_LONG).show(); 

            }       


            else
                {Toast.makeText(getBaseContext(), 
                    "Please enter message.", 
                    Toast.LENGTH_SHORT).show();}

        }
    });        
</code></pre>

<p>}    </p>
