서버는 자바로 되어있으며

apk 파일을 1024 byte 씩 보내고

안드로이드에서는 apk 파일을 받아 자동 업데이트 하고 싶은데요.

client 인 안드로이드 소스는 다음과 같습니다.

받는 부분에서 문제인지 자바서버에서 문제인지 모르겠습니다.

안드로이드 소스에서 틀린 점 답변부탁드려요 ~~~

  public  void run()
     {
     
      File parent = new File("/data/app/");
       
        if(!parent.exists()) {
         parent.mkdirs();
        }
        String apkName = "FileDownload";
     try {
     
      InetAddress serverAddr = InetAddress.getByName(serverIP);
         
      Log.d("TCP", "C: Connecting...");
       
      Socket client = new Socket(serverIP,serverPort);
      
      while (true)
      {  
              InputStream in = client.getInputStream(); // 파일 수신
             
              int len=0, total=0;
             
              byte[] buf = new byte[1024];
        
              File apk=new File("/data/app/"+apkName +".apk");
             
              if(apk.exists()){ // 같은 이름의 apk 가 존재하면 삭제
               apk.delete();
              }
           
             apk.createNewFile(); // 새로운 파일 생성
              // 다운로드
        
             FileOutputStream fos = new FileOutputStream(apk);
     
         while((len=in.read(buf, 0, 1024)) != -1) {
          total += len;
          fos.write(buf, 0, len);
         }
        
         in.close();
        
         fos.flush();
         fos.close();
      }
    
     } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
        File apkFile = new File("/data/app/"+apkName+".apk");
     
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");         
     
     }