Is it possible to restrict an app's permissions to a specific folder(s) (and subfolders)? When installing an app, depending on the app, access to the filesystem is required and requested at the time of install. Is it possible to restrict this to specific folders(s) and their subfolders? For example a photo editor or diary app: why would such apps need to be able to access the whole filesystem.

If not it might not be a bad idea, security-wise...
Could work in theory.

Every app installed on an android phone is given a user id starting from 10000 for the first app and a group with the same id is created.

BusyBox (and root, maybe?) required!

To get the uid of an app, execute the following in a terminal emulator.

dumpsys package com.example.myapp


Replace com.example.myapp with the package name of your target app.


Format your storage (external/internal) with ext4, assuming you have a backup of all the files.
Restore the backup.
chown and chmod the folders you want to restrict. Basing your restrictions on groups will be a better option.


Again, it's just theory. May or may not work.
If you didn't understand any of the steps, get proper knowledge about them or don't try them. This may cause temporary as well as permanent data loss.