I am trying to put the file throght webdav in android,
after i execute the program, the Logcat appear android.os.NetworkOnMainThreadException
i had try two ways to sloves it, likes the code below
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
and this one
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()  
        .detectDiskReads()  
        .detectDiskWrites()  
        .detectNetwork()   // or .detectAll() for all detectable problems  
        .penaltyLog()  
        .build());  
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()  
        .detectLeakedSqlLiteObjects()  
        .detectLeakedClosableObjects()  
        .penaltyLog()  
        .penaltyDeath()  
        .build());  
it could work but those ways force my project to close,
so i thought its not good ways to use on my project
after that i had been researched on it,
everyone recommended this way to solve it
android.os.NetworkOnMainThreadException. How to solve it?
But i am beginner i dont know how to fill my code in,
I would like to know how could I fill in my code in this way,
Thank you in advance for any assistance that can be provided here.
         loginConfirmBtn.setOnClickListener(new Button.OnClickListener(){
            @Override
            public void onClick(View v) {
                ConnectivityManager connMgr = (ConnectivityManager) 
                    getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
                    if (networkInfo != null && networkInfo.isConnected()) {
                        getIpAddress = ipAddress.getText().toString().trim();
                        getUserName = userName.getText().toString().trim();
                        getPassWord = passWord.getText().toString().trim();
                        uploadFiles(sourceFilePath);
                        Toast.makeText(MainActivity.this, "upload suseeful", Toast.LENGTH_SHORT).show();
                        hideKeyboard();
                    } else {
                        Toast.makeText(MainActivity.this, "make sure you have connected the internet", Toast.LENGTH_SHORT).show();                          
           }
        public void uploadFiles(String dir){
            Log.d("edoc","PutRunGenuine");
            String fileFromEscan = dir;
            Conn conn_adv = new Conn(new Constants(getUserName, getPassWord, getIpAddress, 80));                                conn_adv.setUrl("/collab/my/"+conn_adv.getUser()+"/sourceFilePath2");
            Log.d("edoc","edoc test");
               if (fileFromEscan == null) 
               {
                   return;
               }
               try {                 
               String putAvg = "PUT avg: ";
               ExtractedMethod exm =  new ExtractedMethod();
               exm.run(HTCode.Code.PUT, 1, conn_adv, true, fileFromEscan, 1000, true);
               Log.d("edoc","edoc_message hello");
               synchronized(conn_adv){
                   conn_adv.notify();                           
               }
               } catch (Exception io) {
                   io.printStackTrace();
                   Log.d("edoc","edoc Exception"+io);
                 }
           }
 
     
     
     
     
    