Progress dialog showing after adding a post
<p>i have the following code I want to execute (adding a row to database) it while a progress dialog is showing :</p>

<pre><code>StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http://192.168.1.38/hu/Addpost.php?username="+username+"&amp;fname="+firstname+"&amp;lname="+lastname+"&amp;dop="+now+"&amp;content="+post3+"&amp;type="+post_type2+"");

                try
                {

                    nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                    nameValuePairs.add(new BasicNameValuePair("FirstN",firstname));
                    nameValuePairs.add(new BasicNameValuePair("LastN",lastname));
                    nameValuePairs.add(new BasicNameValuePair("Content",post1));
                    nameValuePairs.add(new BasicNameValuePair("type",post_type));
                    nameValuePairs.add(new BasicNameValuePair("Dateofp",now));
                    nameValuePairs.add(new BasicNameValuePair("username",username));
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                    response = httpclient.execute(httppost);

                    if(response.getStatusLine().getStatusCode()==200)
                    {
                    entity=response.getEntity();
                    if(entity !=null)
                    {
                        Toast.makeText(getBaseContext(),"POST SUCCESFULLY ADDED",Toast.LENGTH_LONG).show(); 
                    }

                    }
                    else
                    {
                        Toast.makeText(getBaseContext(),"ERROR RERTY OR CHECK YOUR CONNECTION",Toast.LENGTH_LONG).show();
                    }





                    wholepost.setText("");





                }
                catch(Exception ex)
                {Toast.makeText(getBaseContext(),"CONNECTION ERROR",Toast.LENGTH_LONG).show();}
</code></pre>

<p>I've tried AsyncTask and threads but nothing worked,and sometimes it worked but the progress dialog was shown after the post was added, any help please ?</p>
