简体   繁体   English

如何制作我的应用程序以便将其安装在SD卡上?

[英]How can I make my app so it can be installed on the sd card?

'On my smart phone there is a option to move your app to external storage. '在我的智能手机上,您可以选择将应用移动到外部存储设备。 On most of the apps, including mine this is greyed out. 在大多数应用程序中,包括我的应用程序都是灰色的。 I tried giving my app permissions to write to external memory, 我尝试将我的应用程序权限写入外部内存,

My app still cannot be moved to external storage. 我的应用程序仍然无法移动到外部存储。 How do you get your app so it can be moved to external storage? 你如何获得你的应用程序,以便它可以移动到外部存储?

See the InstallLocation attribute in the android.manifest 请参阅android.manifest中的InstallLocation属性

http://developer.android.com/guide/topics/data/install-location.html http://developer.android.com/guide/topics/data/install-location.html

If you declare "auto", you indicate that your application may be installed on the external storage, but you don't have a preference of install location. 如果您声明“auto”,则表明您的应用程序可能已安装在外部存储上,但您没有安装位置的首选项。 The system will decide where to install your application based on several factors. 系统将根据几个因素决定安装应用程序的位置。 The user can also move your application between the two locations. 用户还可以在两个位置之间移动您的应用程序。

How to allow users to select the Android app's installation location (SD card or internal storage) 如何让用户选择Android应用的安装位置(SD卡或内部存储)

"Unfortunately, It's not possible to explicitly let user choose where to install your app. “不幸的是,明确让用户选择安装应用的位置是不可能的。

Before it's installed, your app can't run so you can't run any code at that time. 在安装之前,您的应用无法运行,因此您当时无法运行任何代码。

Options you mention: "internalOnly", "auto" and "preferExternal" are only options. 你提到的选项:“internalOnly”,“auto”和“preferExternal”只是选项。

From personal experience, I recommend you to use "auto" unless you have some restrictions that force you to use "internalOnly". 根据个人经验,我建议你使用“自动”,除非你有一些限制迫使你使用“internalOnly”。

"preferExternal" can produce errors on some older devices ("can't open SD card" or something like that, I can't remember)." “preferExternal”可能会在某些旧设备上产生错误(“无法打开SD卡”或类似的东西,我记不住了。)

TL;DR TL; DR

You cant tel it where to go. 你不能去哪里去。 use android:installLocation="preferExternal" in the manifest and itll try its best to put it there. 在清单中使用android:installLocation="preferExternal" ,它会尽力把它放在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM