Idee
Idee

Reputation: 1977

Clear sqlite db when application closes android

I want to delete my sqlite database when the application closes. I tried using a global class and overidded the onTerminate() method.

public class AppController extends Application {

private static AppController mInstance;

public Context context(){
    return mInstance.getApplicationContext();

}

@Override
public void onTerminate() {
    context().deleteDatabase(DbHelper.DATABASE_NAME);
    super.onTerminate();
}

}

Its not working

Upvotes: 0

Views: 522

Answers (1)

laalto
laalto

Reputation: 152927

For an in-memory database that is not persisted to permanent storage, use null as the database file name.

Upvotes: 5

Related Questions