Android 編程下 App Install Location

來源:互聯網
上載者:User

標籤:android   style   c   class   blog   code   

從 API 8 開始(參考官方文檔:App Install Location | Android Developers),你可以將你的應用安裝在外部儲存中(例如,安裝到裝置的 SD 記憶卡上)。這是一個可選的特徵,你可以在你的應用的 AndroidManifest.xml 中聲明 android:installLocation 屬性。如果你沒有聲明這個屬性,你的應用程式將會被安裝在內部儲存,並且不能被移到外置儲存中。

修改 AndroidManifest.xml 檔案中 <manifest> 元素下的 android:installLocation 屬性,賦值為 “preferExternal” 或 “auto”,即可允許系統將應用安裝到外部儲存中。代碼如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"    android:installLocation="preferExternal"    ... >

如果 android:installLocation 屬性聲明為 preferExternal,意味著你要求應用程式安裝在外置儲存,但是系統不保證你的程式一定會被安裝在外部儲存中。如果外部儲存空間已滿,程式將會被安裝在內部儲存。使用者也可以在兩個儲存之間移動你的應用程式。如果聲明了 auto,表明你的應用程式可以安裝在外部儲存,但是你沒有一個安裝位置的偏好。系統會根據一些因素來決定你的應用程式安裝在哪。使用者也可以在兩個儲存之間移動你的程式。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.