jeudi 21 mai 2015

Sync Adapter and SQLite instance

I've created custom syncAdapter for my Android app. Also i've created Sqlite helper that is a singleton.

Next, when i'm trying to login i'm creating a helper instance and it works ok. But after login when i want to call SyncAdapter method onPerformSync()new instance of helper is created.

Helper:

public static DBHelper getInstance(Context context){
    if(instance == null){
        instance = new ManagerDB(context, "DBName");
    }
    return instance;
}

onPerformSync():

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
        mdb = ManagerDB.getInstance(context);
}

Anyone can help?

Aucun commentaire:

Enregistrer un commentaire