I have two functions to save files in the internal memory of my application, one for data in Json and another for Images.
With each new application update, I will need to remove these directories so that the new files are saved instead of the old ones.
Follow the code I'm using to create and save the data.
public static Boolean SaveJsonData(Context context, String dir, String filename, String jsondata) {
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(new File(context.getDir(dir, Context.MODE_PRIVATE), filename));
fileOutputStream.write(jsondata.getBytes(Charset.forName("UTF-8")));
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fileOutputStream != null) {
fileOutputStream.close();
return true;
} else { return false; }
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
}
Files are saved in the directories:
/data/data/br.com.meuapp.app/app_json
/data/data/br.com.meuapp.app/app_icones
How do I remove these two directories with everything inside it?