Я загружаю из Интернета и APK файл обновления с этим кодом:
URL url = new URL(urls[0]);
HttpURLConnection connection2 = (HttpURLConnection) url.openConnection();
connection2.setRequestMethod("GET");
connection2.setDoOutput(true);
connection2.connect();
int lenghtOfFile = connection2.getContentLength();
String PATH = ctx.getFilesDir()+"/";
File apkdir=new File (PATH);
apkdir.mkdirs();
File newInstall=new File(apkdir, "app.apk");
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(newInstall);
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress((int)(total*100/lenghtOfFile));
prog=(int)(total*100/lenghtOfFile);
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {}
return null;
и для открытия файла я использую это:
Intent install=new Intent(Intent.ACTION_VIEW);
install.setDataAndType(Uri.fromFile(new File(ctx.getFilesDir()+"/app.apk")), "application/vnd.android.package-archive");
И тут возникает проблема - явозможность сохранить загруженное приложение в Context.getFilesDir (), но когда я запрашиваю цену установки, logcat говорит: «не удается прочитать androidmanifest.xml. Где вы видите проблему?из соображений безопасности.