Recursive removal of shared_prefs in SettingsFragment
This commit is contained in:
parent
66877d552e
commit
e9d700e671
2 changed files with 16 additions and 2 deletions
|
@ -23,6 +23,7 @@ import static android.view.View.VISIBLE;
|
|||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -464,5 +465,18 @@ public final class LinphoneUtils {
|
|||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
public static void recursiveFileRemoval(File root) {
|
||||
if (!root.delete()) {
|
||||
if (root.isDirectory()) {
|
||||
File[] files = root.listFiles();
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
recursiveFileRemoval(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,8 +96,8 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
}
|
||||
|
||||
private void removePreviousPreferencesFile() {
|
||||
File dir = new File(getContext().getFilesDir().getAbsolutePath() + "shared_prefs");
|
||||
dir.delete();
|
||||
File dir = new File(getActivity().getFilesDir().getAbsolutePath() + "shared_prefs");
|
||||
LinphoneUtils.recursiveFileRemoval(dir);
|
||||
}
|
||||
|
||||
// Inits the values or the listener on some settings
|
||||
|
|
Loading…
Reference in a new issue