This code works when downloading from an apache server no problem. but when testing on using iis 7.5 currenlty installed on win7. it doesn’t seem to work at getInputStream(); although the full address to the file is being shown when debuging and pasting that into the browser starts the download of the apk
Reading this site and the internet have added MIME TYPE .apk application/vnd.android.package-archive
try {
URL url = new URL(prefs.getString("server_address", null) + "/updates/filename.apk");
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
String PATH = Environment.getExternalStorageDirectory() + "/download/";
File file = new File(PATH);
file.mkdirs();
File outputFile = new File(file, "filename.apk");
FileOutputStream fos = new FileOutputStream(outputFile);
InputStream is = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = is.read(buffer)) != -1) {
fos.write(buffer, 0, len1);
}
fos.close();
is.close();
} catch (IOException e) {
Toast.makeText(context, "error!", Toast.LENGTH_LONG).show();
}
just get rid of this code:
first is not necessary, second,
c.setDoOutput(true);is changing request method to POST …and thats why you’re getting 405 method not allowed …