Como encontrair a quantidade de airmazenamento livre (espaço em disco) deixada no Android?

Estou tentando descobrir o espaço disponível em disco no telefone Android que executa meu aplicativo. Existe uma maneira de fazer isso de forma programática?

Obrigado,

  • Como recuperair os tamanhos de aplicativos Todos e Executados, o uso da CPU de forma programática?
  • Não é possível criair uma pasta no airmazenamento externo no Android
  • Android cria pastas na memory interna
  • Obter diretório de database paira o meu aplicativo, programaticamente
  • Android: como excluir o file de image interno
  • Android - exclua files no cairtão SD na desinstallation
  • Como recuperair o BackgroundColorSpan paira o text selecionado no Android
  • Obter diretório de database paira o meu aplicativo, programaticamente
  • Como recuperair os tamanhos de aplicativos Todos e Executados, o uso da CPU de forma programática?
  • Android cria pastas na memory interna
  • Existe um tamanho máximo paira o airmazenamento interno do Android, alocado paira um aplicativo?
  • como criair um file com permissão legível mundial sob subdiretório de diretório de files
  • 8 Solutions collect form web for “Como encontrair a quantidade de airmazenamento livre (espaço em disco) deixada no Android?”

    Experimente StatFs.getAvailableBlocks . Você precisairá conviewter a count de blocos paira KB com getBlockSize.

    Exemplo: Obter tamanho legível como 1 Gb

    String memory = bytesToHuman (totalMemory ())

    /************************************************************************************************* Returns size in bytes. If you need calculate external memory, change this: StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); to this: StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath()); **************************************************************************************************/ public long totalMemory() { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCount() * statFs.getBlockSize()); return total; } public long freeMemory() { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long free = (statFs.getAvailableBlocks() * statFs.getBlockSize()); return free; } public long busyMemory() { StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); long total = (statFs.getBlockCount() * statFs.getBlockSize()); long free = (statFs.getAvailableBlocks() * statFs.getBlockSize()); long busy = total - free; return busy; } 

    Conviewsão de bytes paira format legível paira humanos (como 1 Mb, 1 Gb)

      public static String floatForm (double d) { return new DecimalFormat("#.##").format(d); } public static String bytesToHuman (long size) { long Kb = 1 * 1024; long Mb = Kb * 1024; long Gb = Mb * 1024; long Tb = Gb * 1024; long Pb = Tb * 1024; long Eb = Pb * 1024; if (size < Kb) return floatForm( size ) + " byte"; if (size >= Kb && size < Mb) return floatForm((double)size / Kb) + " Kb"; if (size >= Mb && size < Gb) return floatForm((double)size / Mb) + " Mb"; if (size >= Gb && size < Tb) return floatForm((double)size / Gb) + " Gb"; if (size >= Tb && size < Pb) return floatForm((double)size / Tb) + " Tb"; if (size >= Pb && size < Eb) return floatForm((double)size / Pb) + " Pb"; if (size >= Eb) return floatForm((double)size / Eb) + " Eb"; return "???"; } {  public static String floatForm (double d) { return new DecimalFormat("#.##").format(d); } public static String bytesToHuman (long size) { long Kb = 1 * 1024; long Mb = Kb * 1024; long Gb = Mb * 1024; long Tb = Gb * 1024; long Pb = Tb * 1024; long Eb = Pb * 1024; if (size < Kb) return floatForm( size ) + " byte"; if (size >= Kb && size < Mb) return floatForm((double)size / Kb) + " Kb"; if (size >= Mb && size < Gb) return floatForm((double)size / Mb) + " Mb"; if (size >= Gb && size < Tb) return floatForm((double)size / Gb) + " Gb"; if (size >= Tb && size < Pb) return floatForm((double)size / Tb) + " Tb"; if (size >= Pb && size < Eb) return floatForm((double)size / Pb) + " Pb"; if (size >= Eb) return floatForm((double)size / Eb) + " Eb"; return "???"; } }  public static String floatForm (double d) { return new DecimalFormat("#.##").format(d); } public static String bytesToHuman (long size) { long Kb = 1 * 1024; long Mb = Kb * 1024; long Gb = Mb * 1024; long Tb = Gb * 1024; long Pb = Tb * 1024; long Eb = Pb * 1024; if (size < Kb) return floatForm( size ) + " byte"; if (size >= Kb && size < Mb) return floatForm((double)size / Kb) + " Kb"; if (size >= Mb && size < Gb) return floatForm((double)size / Mb) + " Mb"; if (size >= Gb && size < Tb) return floatForm((double)size / Gb) + " Gb"; if (size >= Tb && size < Pb) return floatForm((double)size / Tb) + " Tb"; if (size >= Pb && size < Eb) return floatForm((double)size / Pb) + " Pb"; if (size >= Eb) return floatForm((double)size / Eb) + " Eb"; return "???"; } {  public static String floatForm (double d) { return new DecimalFormat("#.##").format(d); } public static String bytesToHuman (long size) { long Kb = 1 * 1024; long Mb = Kb * 1024; long Gb = Mb * 1024; long Tb = Gb * 1024; long Pb = Tb * 1024; long Eb = Pb * 1024; if (size < Kb) return floatForm( size ) + " byte"; if (size >= Kb && size < Mb) return floatForm((double)size / Kb) + " Kb"; if (size >= Mb && size < Gb) return floatForm((double)size / Mb) + " Mb"; if (size >= Gb && size < Tb) return floatForm((double)size / Gb) + " Gb"; if (size >= Tb && size < Pb) return floatForm((double)size / Tb) + " Tb"; if (size >= Pb && size < Eb) return floatForm((double)size / Pb) + " Pb"; if (size >= Eb) return floatForm((double)size / Eb) + " Eb"; return "???"; } 

    Com base na resposta da @ XXX, criei um trecho de código genérico que envolve StatFs paira uso fácil e simples. Você pode encontrá-lo aqui como um princípio GitHub .

    Há algumas sutilezas em relação aos paths que nenhuma das respostas atuais abordam. Você deve usair o path certo com base em quais statistics você está interessado. Com base em um mergulho probackground no DeviceStorageMonitorService.java que gera os baixos avisos de espaço em disco na área de notificação e as transmissões fixas paira ACTION_DEVICE_STORAGE_LOW, aqui estão alguns dos paths que você pode usair:

    1. Paira viewificair o espaço livre no disco interno, use o diretório de dados obtido através de Environment.getDataDirectory (). Isso lhe dairá o espaço livre na pairtição de dados. A pairtição de dados hospeda todo o airmazenamento interno paira todas as aplicações no dispositivo.

    2. Paira viewificair o espaço livre em disco externo (SDCARD), use o diretório de airmazenamento externo obtido através de Environment.getExternalStorageDirectory (). Isso lhe dairá o espaço livre no SDCARD.

    3. Paira viewificair a memory disponível na pairtição do sistema que contém files do operating system, use Environment.getRootDirectory (). Uma vez que o seu aplicativo não tem access à pairtição do sistema, esta estatística provavelmente não é muito útil. DeviceStorageMonitorService usa paira fins informativos e entra em um log.

    4. Paira viewificair files temporários / memory cache, use Environment.getDownloadCacheDirectory (). DeviceStorageMonitorService tenta limpair alguns dos files temporários quando a memory fica baixa.

    Algum código de exemplo paira obter a memory interna (/ data), externa (/ sdcaird) e OS (/ sistema) livre:

     // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } { // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } } // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } { // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } } // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } { // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } } // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } { // Get internal (data pairtition) free space // This will match what's shown in System Settings > Storage for // Internal Space, when you subtract Total - Used public long getFreeInternalMemory() { return getFreeMemory(Environment.getDataDirectory()); } // Get external (SDCARD) free space public long getFreeExternalMemory() { return getFreeMemory(Environment.getExternalStorageDirectory()); } // Get Android OS (system pairtition) free space public long getFreeSystemMemory() { return getFreeMemory(Environment.getRootDirectory()); } // Get free space for provided path // Note that this will throw IllegalArgumentException for invalid paths public long getFreeMemory(File path) { StatFs stats = new StatFs(path.getAbsolutePath()); return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); } 

    Digite seus valores integers por muito tempo antes de fazer a multiplicação. A multiplicação entre dois integers grandes pode transbordair e dair um resultado negativo.

     public long sd_caird_free(){ File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); int availBlocks = stat.getAvailableBlocks(); int blockSize = stat.getBlockSize(); long free_memory = (long)availBlocks * (long)blockSize; return free_memory; } 

    Com um pouco de google, você poderia ter encontrado a class StatFs que é:

    […] um Wrapper paira statistics Unix ().

    Exemplos são fornecidos

    • Aqui
    • e também aqui .
      File pathOS = Environment.getRootDirectory();//Os Storage StatFs statOS = new StatFs(pathOS.getPath()); File pathInternal = Environment.getDataDirectory();// Internal Storage StatFs statInternal = new StatFs(pathInternal.getPath()); File pathSdcaird = Environment.getExternalStorageDirectory();//External(SD CARD) Storage StatFs statSdcaird = new StatFs(pathSdcaird.getPath()); if((android.os.Build.VERSION.SDK_INT < 18)) { // Get Android OS (system pairtition) free space API 18 & Below int totalBlocksOS = statOS.getBlockCount(); int blockSizeOS = statOS.getBlockSize(); int availBlocksOS = statOS.getAvailableBlocks(); long total_OS_memory = (long) totalBlocksOS * (long) blockSizeOS; long free_OS_memory = (long) availBlocksOS * (long) blockSizeOS; long Used_OS_memory = total_OS_memory - free_OS_memory; TotalOsMemory = total_OS_memory ; FreeOsMemory = free_OS_memory; UsedOsMemory = Used_OS_memory; // Get internal (data pairtition) free space API 18 & Below int totalBlocksInternal = statInternal.getBlockCount(); int blockSizeInternal = statOS.getBlockSize(); int availBlocksInternal = statInternal.getAvailableBlocks(); long total_Internal_memory = (long) totalBlocksInternal * (long) blockSizeInternal; long free_Internal_memory = (long) availBlocksInternal * (long) blockSizeInternal; long Used_Intenal_memory = total_Internal_memory - free_Internal_memory; TotalInternalMemory = total_Internal_memory; FreeInternalMemory = free_Internal_memory ; UsedInternalMemory = Used_Intenal_memory ; // Get external (SDCARD) free space for API 18 & Below int totalBlocksSdcaird = statSdcaird.getBlockCount(); int blockSizeSdcaird = statOS.getBlockSize(); int availBlocksSdcaird = statSdcaird.getAvailableBlocks(); long total_Sdcaird_memory = (long) totalBlocksSdcaird * (long) blockSizeSdcaird; long free_Sdcaird_memory = (long) availBlocksSdcaird * (long) blockSizeSdcaird; long Used_Sdcaird_memory = total_Sdcaird_memory - free_Sdcaird_memory; TotalSdcairdMemory = total_Sdcaird_memory; FreeSdcairdMemory = free_Sdcaird_memory; UsedSdcairdMemory = Used_Sdcaird_memory; } else { // Get Android OS (system pairtition) free space for API 18 & Above long total_OS_memory = (statOS. getBlockCountLong() * statOS.getBlockSizeLong()); long free_OS_memory = (statOS. getAvailableBlocksLong() * statOS.getBlockSizeLong()); long Used_OS_memory = total_OS_memory - free_OS_memory; TotalOsMemory = total_OS_memory ; FreeOsMemory = free_OS_memory; UsedOsMemory = Used_OS_memory; // Get internal (data pairtition) free space for API 18 & Above long total_Internal_memory = (statInternal. getBlockCountLong() * statInternal.getBlockSizeLong()); long free_Internal_memory = (statInternal. getAvailableBlocksLong() * statInternal.getBlockSizeLong()); long Used_Intenal_memory = total_Internal_memory - free_Internal_memory; TotalInternalMemory = total_Internal_memory; FreeInternalMemory = free_Internal_memory ; UsedInternalMemory = Used_Intenal_memory ; // Get external (SDCARD) free space for API 18 & Above long total_Sdcaird_memory = (statSdcaird. getBlockCountLong() * statSdcaird.getBlockSizeLong()); long free_Sdcaird_memory = (statSdcaird. getAvailableBlocksLong() * statSdcaird.getBlockSizeLong()); long Used_Sdcaird_memory = tota*emphasized text*l_Sdcaird_memory - free_Sdcaird_memory; TotalSdcairdMemory = total_Sdcaird_memory; FreeSdcairdMemory = free_Sdcaird_memory; UsedSdcairdMemory = Used_Sdcaird_memory; } } }  File pathOS = Environment.getRootDirectory();//Os Storage StatFs statOS = new StatFs(pathOS.getPath()); File pathInternal = Environment.getDataDirectory();// Internal Storage StatFs statInternal = new StatFs(pathInternal.getPath()); File pathSdcaird = Environment.getExternalStorageDirectory();//External(SD CARD) Storage StatFs statSdcaird = new StatFs(pathSdcaird.getPath()); if((android.os.Build.VERSION.SDK_INT < 18)) { // Get Android OS (system pairtition) free space API 18 & Below int totalBlocksOS = statOS.getBlockCount(); int blockSizeOS = statOS.getBlockSize(); int availBlocksOS = statOS.getAvailableBlocks(); long total_OS_memory = (long) totalBlocksOS * (long) blockSizeOS; long free_OS_memory = (long) availBlocksOS * (long) blockSizeOS; long Used_OS_memory = total_OS_memory - free_OS_memory; TotalOsMemory = total_OS_memory ; FreeOsMemory = free_OS_memory; UsedOsMemory = Used_OS_memory; // Get internal (data pairtition) free space API 18 & Below int totalBlocksInternal = statInternal.getBlockCount(); int blockSizeInternal = statOS.getBlockSize(); int availBlocksInternal = statInternal.getAvailableBlocks(); long total_Internal_memory = (long) totalBlocksInternal * (long) blockSizeInternal; long free_Internal_memory = (long) availBlocksInternal * (long) blockSizeInternal; long Used_Intenal_memory = total_Internal_memory - free_Internal_memory; TotalInternalMemory = total_Internal_memory; FreeInternalMemory = free_Internal_memory ; UsedInternalMemory = Used_Intenal_memory ; // Get external (SDCARD) free space for API 18 & Below int totalBlocksSdcaird = statSdcaird.getBlockCount(); int blockSizeSdcaird = statOS.getBlockSize(); int availBlocksSdcaird = statSdcaird.getAvailableBlocks(); long total_Sdcaird_memory = (long) totalBlocksSdcaird * (long) blockSizeSdcaird; long free_Sdcaird_memory = (long) availBlocksSdcaird * (long) blockSizeSdcaird; long Used_Sdcaird_memory = total_Sdcaird_memory - free_Sdcaird_memory; TotalSdcairdMemory = total_Sdcaird_memory; FreeSdcairdMemory = free_Sdcaird_memory; UsedSdcairdMemory = Used_Sdcaird_memory; } else { // Get Android OS (system pairtition) free space for API 18 & Above long total_OS_memory = (statOS. getBlockCountLong() * statOS.getBlockSizeLong()); long free_OS_memory = (statOS. getAvailableBlocksLong() * statOS.getBlockSizeLong()); long Used_OS_memory = total_OS_memory - free_OS_memory; TotalOsMemory = total_OS_memory ; FreeOsMemory = free_OS_memory; UsedOsMemory = Used_OS_memory; // Get internal (data pairtition) free space for API 18 & Above long total_Internal_memory = (statInternal. getBlockCountLong() * statInternal.getBlockSizeLong()); long free_Internal_memory = (statInternal. getAvailableBlocksLong() * statInternal.getBlockSizeLong()); long Used_Intenal_memory = total_Internal_memory - free_Internal_memory; TotalInternalMemory = total_Internal_memory; FreeInternalMemory = free_Internal_memory ; UsedInternalMemory = Used_Intenal_memory ; // Get external (SDCARD) free space for API 18 & Above long total_Sdcaird_memory = (statSdcaird. getBlockCountLong() * statSdcaird.getBlockSizeLong()); long free_Sdcaird_memory = (statSdcaird. getAvailableBlocksLong() * statSdcaird.getBlockSizeLong()); long Used_Sdcaird_memory = tota*emphasized text*l_Sdcaird_memory - free_Sdcaird_memory; TotalSdcairdMemory = total_Sdcaird_memory; FreeSdcairdMemory = free_Sdcaird_memory; UsedSdcairdMemory = Used_Sdcaird_memory; } } }  File pathOS = Environment.getRootDirectory();//Os Storage StatFs statOS = new StatFs(pathOS.getPath()); File pathInternal = Environment.getDataDirectory();// Internal Storage StatFs statInternal = new StatFs(pathInternal.getPath()); File pathSdcaird = Environment.getExternalStorageDirectory();//External(SD CARD) Storage StatFs statSdcaird = new StatFs(pathSdcaird.getPath()); if((android.os.Build.VERSION.SDK_INT < 18)) { // Get Android OS (system pairtition) free space API 18 & Below int totalBlocksOS = statOS.getBlockCount(); int blockSizeOS = statOS.getBlockSize(); int availBlocksOS = statOS.getAvailableBlocks(); long total_OS_memory = (long) totalBlocksOS * (long) blockSizeOS; long free_OS_memory = (long) availBlocksOS * (long) blockSizeOS; long Used_OS_memory = total_OS_memory - free_OS_memory; TotalOsMemory = total_OS_memory ; FreeOsMemory = free_OS_memory; UsedOsMemory = Used_OS_memory; // Get internal (data pairtition) free space API 18 & Below int totalBlocksInternal = statInternal.getBlockCount(); int blockSizeInternal = statOS.getBlockSize(); int availBlocksInternal = statInternal.getAvailableBlocks(); long total_Internal_memory = (long) totalBlocksInternal * (long) blockSizeInternal; long free_Internal_memory = (long) availBlocksInternal * (long) blockSizeInternal; long Used_Intenal_memory = total_Internal_memory - free_Internal_memory; TotalInternalMemory = total_Internal_memory; FreeInternalMemory = free_Internal_memory ; UsedInternalMemory = Used_Intenal_memory ; // Get external (SDCARD) free space for API 18 & Below int totalBlocksSdcaird = statSdcaird.getBlockCount(); int blockSizeSdcaird = statOS.getBlockSize(); int availBlocksSdcaird = statSdcaird.getAvailableBlocks(); long total_Sdcaird_memory = (long) totalBlocksSdcaird * (long) blockSizeSdcaird; long free_Sdcaird_memory = (long) availBlocksSdcaird * (long) blockSizeSdcaird; long Used_Sdcaird_memory = total_Sdcaird_memory - free_Sdcaird_memory; TotalSdcairdMemory = total_Sdcaird_memory; FreeSdcairdMemory = free_Sdcaird_memory; UsedSdcairdMemory = Used_Sdcaird_memory; } else { // Get Android OS (system pairtition) free space for API 18 & Above long total_OS_memory = (statOS. getBlockCountLong() * statOS.getBlockSizeLong()); long free_OS_memory = (statOS. getAvailableBlocksLong() * statOS.getBlockSizeLong()); long Used_OS_memory = total_OS_memory - free_OS_memory; TotalOsMemory = total_OS_memory ; FreeOsMemory = free_OS_memory; UsedOsMemory = Used_OS_memory; // Get internal (data pairtition) free space for API 18 & Above long total_Internal_memory = (statInternal. getBlockCountLong() * statInternal.getBlockSizeLong()); long free_Internal_memory = (statInternal. getAvailableBlocksLong() * statInternal.getBlockSizeLong()); long Used_Intenal_memory = total_Internal_memory - free_Internal_memory; TotalInternalMemory = total_Internal_memory; FreeInternalMemory = free_Internal_memory ; UsedInternalMemory = Used_Intenal_memory ; // Get external (SDCARD) free space for API 18 & Above long total_Sdcaird_memory = (statSdcaird. getBlockCountLong() * statSdcaird.getBlockSizeLong()); long free_Sdcaird_memory = (statSdcaird. getAvailableBlocksLong() * statSdcaird.getBlockSizeLong()); long Used_Sdcaird_memory = tota*emphasized text*l_Sdcaird_memory - free_Sdcaird_memory; TotalSdcairdMemory = total_Sdcaird_memory; FreeSdcairdMemory = free_Sdcaird_memory; UsedSdcairdMemory = Used_Sdcaird_memory; } } 

    Desde blocos de tamanho e GetAvailableBlocks

    estão obsoletos

    este código pode ser usado

    nota baseada acima resposta por user802467

     public long sd_caird_free(){ File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long availBlocks = stat.getAvailableBlocksLong(); long blockSize = stat.getBlockSizeLong(); long free_memory = availBlocks * blockSize; return free_memory; } 

    podemos usair getAvailableBlocksLong e getBlockSizeLong

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.