安装:

 

1
String str = "/CanavaCancel.apk";
2
String fileName = Environment.getExternalStorageDirectory() + str;
3
Intent intent = new Intent(Intent.ACTION_VIEW);
4
intent.setDataAndType(Uri.fromFile(new File(fileName)),"application/vnd.android.package-archive");
5
startActivity(intent);
 

卸载:

 

1
Uri packageURI = Uri.parse("package:com.demo.CanavaCancel");  
2
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);  
3
startActivity(uninstallIntent);
 

 Environment拥有一些可以获取环境变量的方法 
package:com.demo.CanavaCancel 这个形式是 package:程序完整的路径 (包名+程序名).