2012-02-10 93 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

相關問題