I use this code for saving app.apk from URL:
Context ctx;
InputStream input = new BufferedInputStream(url.openStream());
FileOutputStream output = ctx.getApplicationContext().openFileOutput("myApp.apk", Context.MODE_WORLD_READABLE);
than I save it from input to file by:
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
And after downloading, which is successfuly finished now I want to prompt installation - I think I should use FileInputStream, but I don't know exactly how.
After downloading, I have code:
Intent install=new Intent(Intent.ACTION_VIEW);
install.setDataAndType(Uri.fromFile(xxx - AND HERE I AM STUCK), "application/vnd.android.package-archive");
ctx.startActivity(install);
I have tried ctx.getApplicationContext().openFileInput("myApp.apk")
, but Uri.fromFile needs file and I am giving it openFileInput. Do you know how to solve it?
Thx
Edit: anyobody knows some some solution?