android downloading apk file from internet results in parsing error
When I try to download file using the following code and run the apk file, it always results in "Parsing Error". I am clueless. Any help is appreciated.

 try
                  {
                   URL url  = new URL("http://10.0.0.1/test.apk"); 
                         URLConnection conexion = url.openConnection(); 
                         conexion.connect();
                         int lenghtOfFile = conexion.getContentLength();
                         InputStream is=url.openStream();
                         FileOutputStream fos=new FileOutputStream("/flash/test.apk");
                        byte data[]=new byte[1024];
                        int count=0;
                        long total=0;
                        int progress=0;
                        
                        while ((count=is.read(data)) != -1) 
                         { 
                             total += count; 
                             int progress_temp = (int)total*100/lenghtOfFile; 
                             if(progress_temp%10 == 0 && progress != progress_temp){ 
                                 progress = progress_temp; 
                                 Log.v("APK Download", "total = "+progress);  
                                // Log.v
                             } 
                             fos.write(data, 0, count); 
                         } 
                  
                         is.close(); 
                         fos.close(); 

                         Log.v("APK Download", "Download Done");  
                         
                        
                                             
                  }catch (Exception e){}
                  
android downloading apk file from internet results in parsing error
===

When I try to download file using the following code and run the apk file, it always results in "Parsing Error". I am clueless. Any help is appreciated.

 try
                  {
                   URL url  = new URL("http://10.0.0.1/test.apk"); 
                         URLConnection conexion = url.openConnection(); 
                         conexion.connect();
                         int lenghtOfFile = conexion.getContentLength();
                         InputStream is=url.openStream();
                         FileOutputStream fos=new FileOutputStream("/flash/test.apk");
                        byte data[]=new byte[1024];
                        int count=0;
                        long total=0;
                        int progress=0;
                        
                        while ((count=is.read(data)) != -1) 
                         { 
                             total += count; 
                             int progress_temp = (int)total*100/lenghtOfFile; 
                             if(progress_temp%10 == 0 && progress != progress_temp){ 
                                 progress = progress_temp; 
                                 Log.v("APK Download", "total = "+progress);  
                                // Log.v
                             } 
                             fos.write(data, 0, count); 
                         } 
                  
                         is.close(); 
                         fos.close(); 

                         Log.v("APK Download", "Download Done");  
                         
                        
                                             
                  }catch (Exception e){}
                  