Specific folder permission Android 11

I search in the community but found nothing related to my query !

How to ask permission like this screenshot in Android 11?
I need delete and paste file permission in others app private folder

Thanks in Advance​:smiling_face_with_three_hearts:

You already asked that. Don’t double post. That is not allowed.

I have tried all files access extension

Can you teach me how to get specific folder permission in android 11 like this?

Thanks in Advance​:smiling_face_with_three_hearts:

I would always advise against helping via DM. The purpose of a community is to help each other not for private sessions.

I think you didn’t read my previous reply.

Please read my previous post & see screenshot.
I need solution for that problem. I read your hole post, but I need solution for this problem what the girl asked you

My problem: SAF: App Inventor implementation of Storage Access Framework - #103 by SamirTalukder

Girl Asked: SAF: App Inventor implementation of Storage Access Framework - #50 by Shreya.ig

The solution was provided just a few posts below.

I understand.

Please read #103 post. Please I badly need this

https://community.kodular.io/t/saf-app-inventor-implementation-of-storage-access-framework/144020/103?u=samirtalukder

Sorry for disturbing you. Please teach me how to do it

Sorry, you don’t.
I can’t provide you any block until you show me what you have tried (blocks).


SAF is for making files accessible to your app, though this extension provides methods to read/write to them. Since document is accessible to your app you can do many things with that, but not with this extension. :sweat_smile:

1 Like

I know i am not using your this extension. But I am using your Filetools extension and File component
As you are a file Expert i thought you could help me
Here is my example blocks this is not the original app or block

Taking permission of all files is not a good idea

Can you teach me how to get specific folder permission in android 11 like this?

Please read the first post to know how this extension works.

I read that before. I know I am asking something not related to this extension. I was created a post for that problem but moderator unlisted that post because i asked you here.

Can you solve my problem? As you are a storage Expert.

I just need to know how to get permission of specific folder of other app Private folder in Android 11

That is the problem when you start posting in multiple places. Let’s see if i can fix that.

How to do it in koduler?

1

okay so all of these people saying you cannot access app specific folders, are absolutely wrong, heres how u do it:

Step 1: get the permission of the folder you want,

public void openDirectory() {

String path = Environment.getExternalStorageDirectory() + "/Android/data/com.pubg.krmobile/whatever folder you want to access";
File file = new File(path);
String startDir, secondDir, finalDirPath;

if (file.exists()) {
    startDir = "Android%2Fdata%2Fcom.pubg.krmobile%2Fthefilder%2Fsubfolder%2Fdeepersubfolder";
} 

StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE);

Intent intent = sm.getPrimaryStorageVolume().createOpenDocumentTreeIntent();


Uri uri = intent.getParcelableExtra("android.provider.extra.INITIAL_URI");

String scheme = uri.toString();

Log.d("TAG", "INITIAL_URI scheme: " + scheme);

scheme = scheme.replace("/root/", "/document/");

finalDirPath = scheme + "%3A" + startDir;

uri = Uri.parse(finalDirPath);

intent.putExtra("android.provider.extra.INITIAL_URI", uri);

Log.d("TAG", "uri: " + uri.toString());

try {
    startActivityForResult(intent, 6);
} catch (ActivityNotFoundException ignored) {

}}

step 2: write an onactivityresult to get the path

public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    
    if (resultCode == RESULT_OK) {
        if (data != null) {
            uri = data.getData();
            if (uri.getPath().endsWith(".Statuses")) {
                Log.d("TAG", "onActivityResult: " + uri.getPath());
                final int takeFlags = data.getFlags()
                                              & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    getContentResolver().takePersistableUriPermission(uri, takeFlags);
                }
                
                // these are my SharedPerfernce values for remembering the path
                prefHelper.setIsScopePermissionGranted(true);
                prefHelper.setSavedRoute(uri.toString());
                
                // save any boolean in pref if user given the right path so we can use the path 
                // in future and avoid to ask permission more than one time
                
                startActivity(new Intent(this, MainDashboardActivity.class));
                finish();
                
            } else {
                // dialog when user gave wrong path
                showWrongPathDialog();
            }
            
        }
    }}

step 3: Get the files one by one from here

 if (Build.VERSION.SDK_INT >= 29) {
            // uri is the path which we've saved in our shared pref
            DocumentFile fromTreeUri = DocumentFile.fromTreeUri(context, uri);
            DocumentFile[] documentFiles = fromTreeUri.listFiles();
            
            
            for (int i = 0; i < documentFiles.length; i++) {
                documentFiles[i].getUri().toString() //uri of the document
                }
            }
        }

and voila, you now have access to that folder using the path saved in shared prefrences

well, I’m confused… your question is how to do it in Kodular, isn’t it?
so to access files, which are stored outside of the app or the shared directories, you can use the SAF extension

And you provide some code snippets which show, how to do it?
Can you please provide a link to those code snippets?

Taifun

2 Likes

I want to access: Android/data/com.other.app/some files
I want want to read data of other app
Here is the link to do it in Android studio