From a4fa63bb819cbfe385ee9e0a29c053ac75fb3b6d Mon Sep 17 00:00:00 2001 From: Sebastian Esau Date: Fri, 7 Sep 2018 13:46:12 +0200 Subject: [PATCH] =?UTF-8?q?Storrage=20Methoden=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../camera/ImagePicker/PickImage.java | 2 -- .../camera/{ => ImagePicker}/Storrage.java | 33 +++++-------------- 2 files changed, 8 insertions(+), 27 deletions(-) rename app/src/main/java/com/example/sebastianesau/camera/{ => ImagePicker}/Storrage.java (63%) diff --git a/app/src/main/java/com/example/sebastianesau/camera/ImagePicker/PickImage.java b/app/src/main/java/com/example/sebastianesau/camera/ImagePicker/PickImage.java index 063ae0d..1e0f986 100644 --- a/app/src/main/java/com/example/sebastianesau/camera/ImagePicker/PickImage.java +++ b/app/src/main/java/com/example/sebastianesau/camera/ImagePicker/PickImage.java @@ -15,8 +15,6 @@ import android.util.Log; import android.widget.Toast; -import com.example.sebastianesau.camera.Storrage; - import java.io.File; import java.io.IOException; import java.util.ArrayList; diff --git a/app/src/main/java/com/example/sebastianesau/camera/Storrage.java b/app/src/main/java/com/example/sebastianesau/camera/ImagePicker/Storrage.java similarity index 63% rename from app/src/main/java/com/example/sebastianesau/camera/Storrage.java rename to app/src/main/java/com/example/sebastianesau/camera/ImagePicker/Storrage.java index dfb1df4..00710f9 100644 --- a/app/src/main/java/com/example/sebastianesau/camera/Storrage.java +++ b/app/src/main/java/com/example/sebastianesau/camera/ImagePicker/Storrage.java @@ -1,4 +1,4 @@ -package com.example.sebastianesau.camera; +package com.example.sebastianesau.camera.ImagePicker; import android.os.Environment; import android.os.StatFs; @@ -7,8 +7,6 @@ public class Storrage { - //TODO testen mit File.getUsableSpace() - public static boolean isExternalStorrageReady() { return isExternalStorageAvailable() && !isExternalStorageReadOnly(); } @@ -31,50 +29,35 @@ private static boolean isExternalStorageAvailable() { public static long getFreeInternalStorrageSize() { File path = Environment.getDataDirectory(); - StatFs stat = new StatFs(path.getPath()); - long free_memory = stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); //return value is in bytes - - return free_memory; + return path.getUsableSpace(); } public static long getUsedInternalStorrageSize() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long free_memory = (stat.getBlockCountLong() - stat.getAvailableBlocksLong()) * stat.getBlockSizeLong(); //return value is in bytes - return free_memory; } public static long getInternalStorrageSize() { File path = Environment.getDataDirectory(); - StatFs stat = new StatFs(path.getPath()); - long free_memory = stat.getBlockCountLong() * stat.getBlockSizeLong(); //return value is in bytes - - return free_memory; + return path.getTotalSpace(); } - public static long getFreeExternalStorrageSize(){ - + public static long getFreeExternalStorrageSize() { File path = Environment.getExternalStorageDirectory(); - StatFs stat = new StatFs(path.getPath()); - long free_memory = stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); //return value is in bytes - - return free_memory; + return path.getUsableSpace(); } - public static long getUsedExternalStorrageSize(){ + public static long getUsedExternalStorrageSize() { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long free_memory = (stat.getBlockCountLong() - stat.getAvailableBlocksLong()) * stat.getBlockSizeLong(); //return value is in bytes - return free_memory; } - public static long getExternalStorrageSize(){ + public static long getExternalStorrageSize() { File path = Environment.getExternalStorageDirectory(); - StatFs stat = new StatFs(path.getPath()); - long free_memory = stat.getBlockCountLong() * stat.getBlockSizeLong(); //return value is in bytes - - return free_memory; + return path.getTotalSpace(); } }