2012-02-10 95 views
6

我能够安装使用下面的代码保存在SD卡的APK文件apk文件:的Android如何安装存储资产文件夹

Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.fromFile(new File("/mnt/sdcard/downloads/Sample.apk")), "application/vnd.android.package-archive"); 
startActivity(intent); 

我怎么能安装在存储资产文件夹中的APK文件?可能吗?

回答

9

使用下面的代码写在SD卡的文件:按照 How to copy files from 'assets' folder to sdcard? ,并从该路径安装:

Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive"); 
startActivity(intent); 
+0

感谢兄弟..不错的主意它的伟大工程! – Sandy 2012-02-10 05:45:49

+4

手机没有SD卡但只有内存的情况是什么? – 2013-02-22 07:15:12

+0

我相信这个调用指向/ sdcard - 内部内存 – Clocker 2016-10-04 17:26:08

相关问题