When I target api 30 and try to retrieve the list of files in the path "/data/data" (with root permissions), I only get the folder of my app, while with api 29 or lower I get all the files present.
How can I retrieve all files even with api 30?
Code used:
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.topjohnwu.superuser.Shell
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val result = Shell.su("ls -la /data/data").exec()
Log.e("files", result.out.toString())
}
}
I used this library for root: https://github.com/topjohnwu/libsu
These are the new limitations added in Android 11: https://developer.android.com/about/versions/11/privacy/storage
Document access restrictions
To give developers time for testing, the following changes related > to the Storage Access Framework (SAF) take effect only if your app targets Android 11 or higher.
Access to directories
You can no longer use the ACTION_OPEN_DOCUMENT_TREE intent action to request access to the following directories:
- The root directory of the internal storage volume.
- The root directory of each SD card volume that the device manufacturer considers to be reliable, regardless of whether the card is emulated or removable. A reliable volume is one that an app can successfully access most of the time.
- The Download directory.
Access to files
You can no longer use the ACTION_OPEN_DOCUMENT_TREE or the ACTION_OPEN_DOCUMENT intent action to request that the user select individual files from the following directories:
- The
Android/data/directory and all subdirectories.- The
Android/obb/directory and all subdirectories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With