![](/img/trans.png)
[英]How to check if a SD Card has been inserted to the tablet or not : Android?
[英]How to find out if an App has been moved to SD card on Android
我使用了installLocation,可以確定是否可以移動應用程序。 但是,當我們想知道某個應用程序是否已移至SD卡時,我無法弄清楚會發生什么。
ApplicationInfo
屬性FLAG_EXTERNAL_STORAGE
僅告訴您應用程序是否已安裝到SD,而不是已移至。 我正在生成可以移動到SD卡的應用程序列表。 因此,我生成的第一個列表是使用清單的installLocation
。 從這個列表中我可以過濾出已經移動到SD卡的應用程序。
要檢查應用程序是否安裝在SD卡中,請執行以下操作:
ApplicationInfo io = context.getApplicationInfo();
if(io.sourceDir.startsWith("/data/")) {
//application is installed in internal memory
} else if(io.sourceDir.startsWith("/mnt/") || io.sourceDir.startsWith("/sdcard/")) {
//application is installed in sdcard(external memory)
}
如果您的安裝位置是自動的,您可以將應用程序從SD卡移動到手機,反之亦然。 您可以在設備應用程序管理器中手動檢查應用程序位置。
假設這個問題(及其接受的答案)可能會有所幫助。
簡而言之:getApplicationInfo()。sourceDir,如此處所述 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.