I developed an application, especially for Exam, this app disallows students to use the back button (will clear its data and cache) and the Recent App button also disabled, but this app has a weakness: Students still can open another application (e.g Browsing) when they click the Home button.
I tried to do like this in the onStop method
@Override
protected void onStop(){
super.onStop();
this.finish();
clearApplicationData();
}
And this is the code of the clearApplicationData method :
public void clearApplicationData() {
File cache = getCacheDir();
File appDir = new File(cache.getParent());
if (appDir.exists()) {
String[] children = appDir.list();
for (String s : children) {
if (!s.equals("lib")) {
deleteDir(new File(appDir, s));
Log.i("ERROR", " File /data/data/APP_PACKAGE/" + s + "");
}
}
}
}
But it's not working, the app can still be opened and the data isn't cleared Can you tell me what's wrong?