Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeinnumer committed Feb 19, 2021
1 parent 8485156 commit 9fb7ab6
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</h1>

<div align="center">
<a><img src="https://img.shields.io/badge/Version-2.1.0-brightgreen.svg?style=flat"></a>
<a><img src="https://img.shields.io/badge/Version-2.2.0-brightgreen.svg?style=flat"></a>
<a><img src="https://img.shields.io/badge/ID-gzeinnumer-blue.svg?style=flat"></a>
<a><img src="https://img.shields.io/badge/Java-Suport-green?logo=java&style=flat"></a>
<a><img src="https://img.shields.io/badge/Kotlin-Suport-green?logo=kotlin&style=flat"></a>
Expand Down Expand Up @@ -49,6 +49,7 @@ This library need Permission you can use this step [**MultiPermission**](https:/
- [Create Folder](https://github.com/gzeinnumer/EasyExternalDirectoryAndroid/blob/master/README_1.md#create-folder)
- [Is File Exists](https://github.com/gzeinnumer/EasyExternalDirectoryAndroid/blob/master/README_1.md#is-file-exists)
- [Delete Folder](https://github.com/gzeinnumer/EasyExternalDirectoryAndroid/blob/master/README_1.md#delete-folder)
- [Check Available Size In Storage](https://github.com/gzeinnumer/EasyExternalDirectoryAndroid/blob/master/README_1.md#check-available-size-in-storage)

#### [Function Global File](https://github.com/gzeinnumer/EasyExternalDirectoryAndroid/blob/master/README_2.md)
- [Create File](https://github.com/gzeinnumer/EasyExternalDirectoryAndroid/blob/master/README_2.md#create-file)
Expand Down Expand Up @@ -120,6 +121,8 @@ This library need Permission you can use this step [**MultiPermission**](https:/
- Support SDK 16
- **2.1.0**
- Message Error CallBack
- **2.2.0**
- Free Space Storage Checker

---
# Contribution
Expand Down
19 changes: 19 additions & 0 deletions README_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ This library need Permission you can use this step [**MultiPermission**](https:/
| `initFolder` | `boolean` | `String... folderName` | Make folder in own app folder in external |
| `isFileExists` | `boolean` | `String path` | To check is `directory` or `file` has created or not |
| `deleteDir` | `boolean` | `String path` | To Delete `directory` or `file` |
| `getAvailableSpaceInKB` | `long` | `none` | Check available size in `KB` |
| `getAvailableSpaceInMB` | `long` | `none` | Check available size in `MB` |
| `getAvailableSpaceInGB` | `long` | `none` | Check available size in `GB` |
| `checkAvailableSpaceInKB` | `boolean | `long requestSize` | Request empty storage with `KB` |
| `checkAvailableSpaceInMB` | `boolean | `long requestSize` | Request empty storage with `MB` |
| `checkAvailableSpaceInGB` | `boolean | `long requestSize` | Request empty storage with `GB` |

---
### Step 1. Enable Fitur.
Expand Down Expand Up @@ -112,6 +118,19 @@ boolean isExists = FGDir.isFileExists("/folder1");
boolean isDeleted = FGDir.deleteDir("/folder1");
```

#
#### Check Available Size In Storage
```java
long sizeInKB = getAvailableSpaceInKB();
long sizeInMB = getAvailableSpaceInMB();
long sizeInGB = getAvailableSpaceInGB();
```
```java
boolean isSizeAvailable = checkAvailableSpaceInKB(60); //if free space more than 60KB return true
boolean isSizeAvailable = checkAvailableSpaceInMB(60); //if free space more than 60MB return true
boolean isSizeAvailable = checkAvailableSpaceInGB(60); //if free space more than 60GB return true
```

#
[FullCode](https://github.com/gzeinnumer/EasyExternalDirectoryAndroid/blob/master/example/CreateFolder/MainActivity.java)

Expand Down
48 changes: 48 additions & 0 deletions eeda/src/main/java/com/gzeinnumer/eeda/helper/FGDir.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gzeinnumer.eeda.helper;

import android.os.Environment;
import android.os.StatFs;
import android.util.Log;

import java.io.File;
Expand Down Expand Up @@ -118,6 +119,53 @@ public static boolean deleteDir(String path) {
return new File(FGDir.getStorageCard + FGDir.appFolder + path).delete();
}

/**
* @return Number of kilo bytes available on External storage
*/
public static long getAvailableSpaceInKB() {
final long SIZE_KB = 1024L;
long availableSpace;
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
return availableSpace / SIZE_KB;
}

/**
* @return Number of Mega bytes available on External storage
*/
public static long getAvailableSpaceInMB() {
final long SIZE_KB = 1024L;
final long SIZE_MB = SIZE_KB * SIZE_KB;
long availableSpace;
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
return availableSpace / SIZE_MB;
}

/**
* @return Number of gega bytes available on External storage
*/
public static long getAvailableSpaceInGB() {
final long SIZE_KB = 1024L;
final long SIZE_GB = SIZE_KB * SIZE_KB * SIZE_KB;
long availableSpace;
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
return availableSpace / SIZE_GB;
}

public static boolean checkAvailableSpaceInKB(long requestSize) {
return getAvailableSpaceInKB() > requestSize;
}

public static boolean checkAvailableSpaceInMB(long requestSize) {
return getAvailableSpaceInMB() > requestSize;
}

public static boolean checkAvailableSpaceInGB(long requestSize) {
return getAvailableSpaceInGB() > requestSize;
}

public interface MessageCallBack {
void messageError(String msg);
}
Expand Down

0 comments on commit 9fb7ab6

Please sign in to comment.