I am creating an application that installs applications downloaded from the server. I would like to install this application. After downloading the file, the code for the method that I use to install is here:
public void Install(String name)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File
(Environment.getExternalStorageDirectory() + "/ContentManager/" + name)), "application/vnd.android.package-archive");
startActivity(intent);
File file = new File(Environment.getExternalStorageDirectory() + "/ContentManager/"+name);
file.delete();
}
I want the apk file to be deleted from the SD card after installation is complete. This code deletes it after the installation starts, which causes the installation to fail. I am pretty friends with android and will be very grateful for the help. Basically, I try to wait for the installation to complete before continuing with the process.
source
share