@arcastro,  @Stephan Celis,  @Egor and @Mohan thank you very much for your help. All your ideas helped me a lot. 
I add a separate thread to connect to the network and download data @Egor your question made me realize what I did wrong
Thank you all
For developers who stuck in the same problem which i did hear is how i did it
place below "updateHandler" code in your class
 private Handler updateHandler = new Handler()
   {
       @Override
       public void handleMessage(Message msg)
       {
           if (msg.what == -999)
           {
            Log.d("recieve data","from http://jayanga.esplprojects.com/xx/data.xml to update");
                     DatabaseHandler db = new DatabaseHandler(getApplicationContext());
                     String xml = XML.getXML("http://jayanga.esplprojects.com/xx/data.xml");
                     Document doc = XML.XMLfromString(xml);
                    int numResults = XML.numResults(doc);
                     if((numResults <= 0)){
                            Toast.makeText(getApplicationContext(), "SORRY No data were found", Toast.LENGTH_LONG).show();  
                            finish();
                     }//if((numResults <= 0))
                     NodeList nodes = doc.getElementsByTagName("result");
                     for (int i = 0; i < nodes.getLength(); i++) {                          
                            Element e = (Element)nodes.item(i);
                        //  String s = "...."+XML.getValue(e, "name");
                            // Inserting Contacts
                            Log.d("Insert: ", "Inserting ..");
                            db.addContact(new Details(XML.getValue(e, "name"),Double.parseDouble( XML.getValue(e, "latitude"))
                                    , Double.parseDouble(XML.getValue(e, "longitude")),XML.getValue(e, "contact") ));
                     }// for (int i = 0; i < nodes.getLength(); i++)
                     db.close();
                     Toast.makeText(getApplicationContext(), "Database Successfully Updated", Toast.LENGTH_LONG).show();
                     displayLocations();
           }
       }
   };
Then call updateHandler from where you want to run the thread
int get_update_data = -999;
            Message theMessage = updateHandler .obtainMessage(get_update_data);
            updateHandler.sendMessage(theMessage);//Sends the message to the UI handler.