Q:

On Main activity unable to show popup in android Android Can't create handler inside thread that has not called Looper.prepare()

To insert input values into mysql database I write insert() method
after insert method inserted data successfully I want to show Dialog popup with message "Success"
but I'm unable to execute the dialog.show() code :(
may be because of I pass MainActivity.this
Code in MainActivity 

public class MainActivity extends Activity {

//call insert method to insert data into mysql
 new Thread(new Runnable() {
                                    public void run() {
                                        insert(name.getText().toString());                                      
                                    }
                                }).start();

}

public void insert(final String name){

//insert logic code
//returns true if success

if(true)
{
    AlertDialog. Builder alertDialogBuilder = new AlertDialog. Builder(MainActivity.this);
                        alertDialogBuilder.setMessage("Record submited successfully!"); 
                          alertDialogBuilder.setTitle("Success!"); 
                          alertDialogBuilder.setCancelable(false);
                          alertDialogBuilder.setNeutralButton(android. R.string.ok,
                             new DialogInterface. OnClickListener() {
                             public void onClick(DialogInterface dialog, int whichButton){
                                 dialog.cancel();
                                 }
                             })
                          .show();  

}

}//END class MainActivity

here is my problem :(

A:

Call show() on the main application thread, such as from onPostExecute() of an AsyncTask.