I am using LIBSU by John Wu to run superuser commands on my android app. My objective is to create a folder with mkdir but it seems that the command runs successfully but the folder isn't created.
Here's my code:
fun createDialog(packageInfo: ApplicationInfo) {
val folderName = "LOL"
val packageName = packageInfo.packageName
sudo(packageName)
}
fun sudo(packageName: String) {
val path = "/data/data/$packageName"
val file = "lol"
Shell.su("mount -o remount,rw $path").exec()
if (!Shell.getShell().isRoot) {
Log.e("Daniel", "Not rooted")
}
val result = Shell.su("mkdir -p $path/$file").exec()
Shell.su("mount -o remount,ro $path").exec()
Log.e("Daniel", result.isSuccess().toString())
}
I found a fix to this problem. I don't know the exact reason why it didn't work but I need to use '-mm' as well while executing a command. For example: 'su -mm ls /data/data'
It fixed the problem.