Android Studio Как обойти разрешения на корневые устройстваJAVA

Программисты JAVA общаются здесь
Anonymous
Android Studio Как обойти разрешения на корневые устройства

Сообщение Anonymous »

Код: Выделить всё

// TODO: Copy the file somewhere non-rooted, write, replace
public void saveProperties(UIProperties properties) {
try (Writer writer = new FileWriter(FILEPATH)) {
// Serialize the UIProperties object to JSON and write it to the file
gson.toJson(properties, writer);
Log.i(TAG, "UI Properties saved to " + FILEPATH);
}
catch (IOException e) {
Log.e(TAG, "Could not save UI Properties to " + FILEPATH);
Log.e(TAG, e.getMessage());
}
}

// TODO: Copy the file somewhere non-rooted, read, use
public UIProperties loadProperties() {
try(Reader reader = new FileReader(FILEPATH)) {
// Deserialize the JSON from the file into a UIProperties object
UIProperties properties = gson.fromJson(reader, UIProperties.class);

// If the file exists but is empty or contains invalid JSON, fromJson might return null
if (properties == null) {
Log.e(TAG, "JSON file " + FILEPATH + " is empty or invalid. Returning new UIProperties.");
return new UIProperties();
}

return  properties;
}
catch (IOException e) {
Log.e(TAG, "Could not load UI properties from " + FILEPATH);
Log.e(TAG, e.getMessage());
return new UIProperties();
}
catch (JsonSyntaxException e) {
Log.e(TAG, "Invalid JSON syntax in" + FILEPATH);
return new UIProperties();
}
}
< /code>
Как мне обойти разрешения в Android Studio, если у меня есть корневое устройство? Я хочу загрузить и сохранить файл json из каталога, который обычно требует корневого на Android 15. < /P>
/data/misc/com.crjase.systemuihook/properties.json: open failed: EACCES (Permission denied)
Стандартное написание файлов не использует корень, который я дал своему приложению, поэтому мне интересно, как я могу это сделать.

Подробнее здесь: https://stackoverflow.com/questions/796 ... ed-devices

Вернуться в «JAVA»