PavelX 1 Posted September 4, 2020 (edited) Hi, I try to run the following code on Android (10.4 Sydney) fn:=TPath.Combine(TPath.GetSharedDocumentsPath(),'OLA'); TDirectory.CreateDirectory(fn); // or ForceDirectories(fn) -> I tried both functions if TDirectory.Exists(fn,false) then showmessage('Ok') else showmessage('Failed'); And the code fail. The same code works without any problem with 10.3.3 (using the same phone) Note: On both environments I have used default User Permissions. including "Write external storage" Did you encountered this problem? - how did you solved? Thank you in advance, Pavel Edited September 4, 2020 by PavelX Share this post Link to post
Dave Nottage 557 Posted September 4, 2020 The following worked fine for me: procedure TForm1.Button1Click(Sender: TObject); begin PermissionsService.RequestPermissions(['android.permission.READ_EXTERNAL_STORAGE', 'android.permission.WRITE_EXTERNAL_STORAGE'], procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>) begin // NOTE: I am assuming the user granted permission, here! CreateFolder; end ); end; procedure TForm1.CreateFolder; var fn: string; begin fn := TPath.Combine(TPath.GetSharedDocumentsPath, 'OLA'); ForceDirectories(fn); if TDirectory.Exists(fn) then Button1.Text := 'OK' else Button1.Text := 'Failed'; end; Delphi 10.4.1, Android 11 device (Pixel3a) 1 Share this post Link to post
PavelX 1 Posted September 4, 2020 Dave, first of all I want to thank you for your fast reply. It looks that that you have right. Indeed environment User Permissions has no effect Thanks again, Pavel Share this post Link to post
Dave Nottage 557 Posted September 4, 2020 25 minutes ago, PavelX said: Indeed environment User Permissions has no effect It will not work if you do not have the permissions checked in the project options. Share this post Link to post