diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/async/AccountAction.java b/app/src/main/java/org/nuclearfog/twidda/backend/async/AccountAction.java index 1c189091..b6718d58 100644 --- a/app/src/main/java/org/nuclearfog/twidda/backend/async/AccountAction.java +++ b/app/src/main/java/org/nuclearfog/twidda/backend/async/AccountAction.java @@ -40,6 +40,7 @@ public class AccountAction extends AsyncExecutor logins = getLogins(); + List webPushs = getWebPushs(); // reset database adapter.resetDatabase(); // restore saved logins for (Account login : logins) { saveLogin(login); } + // restore web push subscription + for (WebPush webPush : webPushs) { + savePushSubscription(webPush); + } } } + /** + * get all web push subscriptions + */ + private List getWebPushs() { + List result = new LinkedList<>(); + + SQLiteDatabase db = adapter.getDbRead(); + Cursor c = db.query(PushTable.TABLE, DatabasePush.COLUMNS, null, null, null, null, null); + if (c.moveToFirst()) { + result.add(new DatabasePush(c)); + } + c.close(); + return result; + } + /** * get status information from database *