i've create this method to read a file:
@TargetApi(19)
public String getContentFile(String path) throws FileNotFoundException {
BufferedReader br = new BufferedReader(new FileReader(path));
try {
Toast.makeText(MainActivity.this, "entrato", Toast.LENGTH_SHORT).show();
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.lineSeparator());
line = br.readLine();
}
String everything = sb.toString();
br.close();
return everything;
} catch (Exception e) {
return "error";
}
and i call it in MainActivity, this code work for file in storage folder but not for file in data/data folder, how can i change this? Tha app is for root device, my question is: how to access in other folders? the exception say: open failed: EACCES (Permission denied) so i've change the file permission and it works but how to change permission temporarily?