mercredi 6 mai 2015

database loaded empty after app crashes

I'm experiencing a weird problem with my SQLite Database. When I instantiate my OpenHelper the first time I launch my app, my database is loaded normally and I can retrieve all my data. If the app crashes, the android manager re-pop my app on my first activity. So all the initialization process is the same, but for some reasons the database is loaded without any data.

Here's my OpenHelper constructors:

   public static AppDatabaseHelper getInstance(Context ctx, Handler uiHandler, String companyName){
    if(mInstanceWithHandler==null){
        DATABASENAME=companyName;
        mInstanceWithHandler=new AppDatabaseHelper(ctx);
    }
    return mInstanceWithHandler;
    }

    private AppDatabaseHelper(Context context) {
    super(context, DATABASENAME, null, DATABASE_VERSION);
    this.context = context;
    }

And my datasource

 public AppDataSource(Context context, Handler handler, String companyName) {
    dbHelper = AppDatabaseHelper.getInstance(context, handler, companyName);
    database = dbHelper.getWritableDatabase(); 
    this.context = context;
}

I really can figure out why the same database is loaded but without any data after the app crashes. Is it handled by the system layer?

Aucun commentaire:

Enregistrer un commentaire