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.