OC-1508: App crashes when changing the orientation
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AccountUtils.java
index a4bc778..47269bc 100644 (file)
@@ -75,6 +75,20 @@ public class AccountUtils {
     }\r
 \r
     \r
+    public static boolean exists(Account account, Context context) {\r
+        Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
+                AccountAuthenticator.ACCOUNT_TYPE);\r
+\r
+        if (account != null && account.name != null) {\r
+            for (Account ac : ocAccounts) {\r
+                if (ac.name.equals(account.name)) {\r
+                    return true;\r
+                }\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+    \r
 \r
     /**\r
      * Checks, whether or not there are any ownCloud accounts setup.\r