Wir verwenden folgende Routine, schau mal, ob die bei dir das richtige liefert - würde mich nämlich auch interessieren
:
Delphi-Quellcode:
function GetSdCardPath: JFile;
var
i, nSDK_Level: Integer;
jfMntPath: JFile;
jfList: TJavaObjectArray<JFile>;
sMediaMounted, sPathStorageState:
string;
begin
Result :=
nil;
jfMntPath := TJFile.JavaClass.init( StringToJString( '
/storage' ) );
if jfMntPath.isDirectory
and jfMntPath.exists
then begin
nSDK_Level := TJBuild_VERSION.JavaClass.SDK_INT;
if nSDK_Level >= 19
then begin
sMediaMounted := JStringToString( TJEnvironment.JavaClass.MEDIA_MOUNTED );
jfList := jfMntPath.listFiles;
for i := 0
to jfList.Length-1
do begin
// getStorageState is added in API level 19; deprecated in API level 21, which introduces getExternalStorageState(File). Delphi interface does not supports this method with parameter.
sPathStorageState := JStringToString( TJEnvironment.JavaClass.getStorageState( jfList.Items[i] ) );
if SameText( sPathStorageState, sMediaMounted )
then begin
Result := jfList.Items[i];
Break;
end;
end;
end;
end;
end;