Dim p As Phone
Dim sb As StringBuilder
sb.Initialize
p.Shell("chmod 999", Null, sb, Null)
Dim p As Phone
Dim sb As StringBuilder
sb.Initialize
p.Shell("chmod 777 /data/data/com.android.providers.settings/databases/settings.db", Null, sb, Null)
Java doesn't have native support for platform dependent operations like chmod. However, Android provides utilities for some of these operations via android.os.FileUtils. The FileUtils class is not part of the public SDK and is therefore not supported. So, use this at your own risk:
public int chmod(File path, int mode) throws Exception {
Class fileUtils = Class.forName("android.os.FileUtils");
Method setPermissions =
fileUtils.getMethod("setPermissions", String.class, int.class, int.class, int.class);
return (Integer) setPermissions.invoke(null, path.getAbsolutePath(), mode, -1, -1);
}
Ok. How do I wrap into a B4A Library?
package chmod.chmod;
import java.io.File;
import java.lang.reflect.Method;
public class Chmod {
public int chmod(File path, int mode) throws Exception {
Class fileUtils = Class.forName("android.os.FileUtils");
Method setPermissions =
fileUtils.getMethod("setPermissions", String.class, int.class, int.class, int.class);
return (Integer) setPermissions.invoke(null, path.getAbsolutePath(), mode, -1, -1);
}
}
chmod("/data/data/com.android.providers.settings/databases/settings.db", 0777)