Reputation: 834
i get parse error once i use my function below
public void installFile()
{
String path = "/data/data/com.utsc.smartdictate/";
String filename = "smartdictate.apk";
File file = new File(path + filename);
if(file.exists())
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
}
}
i tried pulling the apk file from the emulator and tried installing it, to test if the file was corrupted or not, however it installed! so i dont know why it is failing.
EDIT: i have "android.permission.INSTALL_PACKAGES" permission added in the manifest
Upvotes: 2
Views: 261
Reputation: 1007584
Most likely, the file is not readable by the installer. Files in your application-local file store are not readable by other processes by default. You will need to either store the file on external storage, or create your file use openFileOutput()
and MODE_WORLD_READABLE
, or create a content provider to serve that file.
Also:
getFilesDir()
to get the root of your application-local file store/data/data/com.utsc.smartdictate/
, but in /data/data/com.utsc.smartdictate/files
, which is what you will get from getFilesDir()
File
constructor insteadUpvotes: 2