Jump to content
philipp.hofmann

Android 10 + SD-Card: .../Android/media/[appName] is not created

Recommended Posts

Hi,

I'm currently migrating from Delphi 12.1 to Delphi 12.3. I noticed that the directory

.../Android/media/[appName] is no longer created on the SD card (same code, only compiled with Delphi 12.3), at least on my Android 10 tablet. The directory
.../Android/data/[appName] is there.

I can't see any difference in the manifest file (see attachment). The only thing that is also noticeable is that with the Delphi 12.1 version I don't have to call PermissionsService.RequestPermissions for READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE at all and it still works. In the Delphi 12.3 version, I need to call it.

Does anyone know more about it. I've already ordered an Android 13 tablet. If this is only an Android<=10 problem, it might be bearable, but it is still a good 16 percent of users for tablets.

Best regards, Philipp

AndroidManifest.Delphi12.1.xml

AndroidManifest.Delphi12.3.xml

Share this post


Link to post

Thanks to @jaenicke
It's necessary now to ask once for Context.getExternalMediaDirs open the path once and then the directory is created on SD card again.
This was not necessary before.
 

uses
  Androidapi.JNIBridge,
  Androidapi.JNI.JavaTypes,
  Androidapi.JNI.GraphicsContentViewText,
  Androidapi.Helpers;

function GetExternalMediaPath: string;
var
  Context: JContext;
  mediaDirs: TJavaObjectArray<JFile>;
  mediaDir: JFile;
begin
  Result := '';
  Context := TJContext.Wrap(SharedActivity);
  if Context <> nil then
  begin
    mediaDirs := Context.getExternalMediaDirs;
    if (mediaDirs <> nil) and (mediaDirs.Length > 0) then
    begin
      mediaDir := mediaDirs.Items[0];
      if mediaDir <> nil then
        Result := JStringToString(mediaDir.getAbsolutePath);
    end;
  end;
end;

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×