I've been trying to find out how to install stored APK from internal memory, but I continually get errors.
I've tried getFilesDir()
but it returns
08-14 03:18:09.127 10089-10089/? W/zipro: Error opening archive /data/user/0/package_name/files/app-release.apk: I/O Error
08-14 03:18:09.127 10089-10089/? D/asset: failed to open Zip archive '/data/user/0/package_name/files/app-release.apk'
08-14 03:18:09.127 10089-10089/? W/PackageInstaller: Parse error when parsing manifest. Discontinuing installation
I've also tried Environment.getDownloadCacheDirectory()
but I get a similar result.
I am attempting to install on a non-rooted device, but I have signature level app permission.
How do I install app on a non-rooted device?
Even
public void installAPKManual(String filename) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File(filename));
intent.setDataAndType(uri, "application/vnd.android.package-archive");
startActivity(intent);
}
doesn't work. Parse error.
Update
It works after I use
file.setReadable(true, false)
to get world readable permission, but I wonder if there is a better way?