Android Question Know Smartphone space

uniplan

Active Member
Licensed User
Longtime User
How i know the smartphone disk space (folder internal and external) ?
thank you
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Process_Globals
    Private nativeMe As JavaObject
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        nativeMe.InitializeContext
    End If
    nativeMe.RunMethod("Test", Null)
End Sub

Inline java
B4X:
#If JAVA
import android.os.Environment;
import android.os.StatFs;

public void Test() {
    
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
    BA.Log("MB free: "+(float)bytesAvailable / (1024.f * 1024.f));
}
#End IF
 
Last edited:
Upvote 0
Top