Jump to content
mrceski

Cannot access in folder documents on Android 11 in Delphi XE 10.4.2

Recommended Posts

I want to read files from documents folder on android in Delphi XE 10.4.2.

Some code work very well in Delphi XE 10.3.3 on Android 10.

Now show message Cannot open file "/storage/emulated/0/documents/Readme.txt". Permission denied.

 

Code:

    WS:=JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE);
    PPS:=jstringtostring(TJManifest_permission.JavaClass.READ_PHONE_STATE);
    RS:=jstringtostring(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE);
    PermissionsService.RequestPermissions([PPS,WS,RS],nil,nil);

 

Open file in memo.

Memo2.Lines.LoadFromFile(TPath.GetSharedDocumentsPath + PathDelim + 'Readme.txt' ,TEncoding.GetEncoding(1251));

 

Edited by mrceski

Share this post


Link to post
1 hour ago, mrceski said:

I want to read files from documents folder on android in Delphi XE 10.4.2.

Why do people keep insisting on using the XE name for things that are not XE?!?  Embarcadero stopped using the XE prefix after XE8.  The current version is "10.4.2 Sydney", period.

Quote

Some code work very well in Delphi XE 10.3.3 on Android 10.

Now show message Cannot open file "/storage/emulated/0/documents/Readme.txt". Permission denied.

Did you read the Android 11 developer documentation?

https://developer.android.com/about/versions/11

 

Google made behavioral changes:

https://developer.android.com/about/versions/11/behavior-changes-all

 

In particular:

https://developer.android.com/about/versions/11/privacy/storage

Edited by Remy Lebeau

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

×