简体   繁体   English

Android - 如何将我的应用程序安装到SD卡

[英]Android - How can i install my app to sd card

I created my android app. 我创建了我的Android应用程序。 I installed my telephone. 我安装了电话。 But it was saved my telephone. 但它保存了我的电话。 I want to save APP and DATABASE to my sd card. 我想将APP和DATABASE保存到我的SD卡中。 Because when people formatted telephone, app and db datas will not delete 因为当人们格式化电话时,app和db数据不会被删除

  1. In your manifest 在你的清单中

     <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="YOUR_PACKAGE" android:installLocation="internalOnly" 

    android:installLocation can be changed to preferExternal for preference to external storage. android:installLocation可以更改为preferExternal以优先选择外部存储。 But this doesn't gurantee the application will be install on external storage, as from the Android references 但这并不保证应用程序将安装在外部存储上,如同从Android引用

    The application prefers to be installed on the external storage (SD card). 该应用程序更喜欢安装在外部存储(SD卡)上。 There is no guarantee that the system will honor this request. 无法保证系统会遵守此请求。 The application might be installed on internal storage if the external media is unavailable or full. 如果外部媒体不可用或已满,则可能会将应用程序安装在内部存储上。 Once installed, the user can move the application to either internal or external storage through the system settings. 安装后,用户可以通过系统设置将应用程序移动到内部或外部存储。

    Read here for more information about manifest elements(as refered by a respected user below) 请阅读此处以获取有关清单元素的更多信息(如下面受尊敬的用户所述)

  2. If the app data is stored as SharedPreference it will be automatically cleared on device format, so you may opt to save your preferences to External Storage from the application using custom preference files. 如果应用程序数据存储为SharedPreference ,它将自动以设备格式清除,因此您可以选择使用自定义首选项文件从应用程序将首选项保存到外部存储。

    Read here for ways to store data on android. 在这里阅读有关在android上存储数据的方法。

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

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