Hi all - I am trying to simply get a count of registered email accounts. But it keeps coming back 0, even though I have setup 2 accounts. The Log entry below indeed shows I'm getting back an accountUuids string of null. Here's the code I'm using (anyone see an obvious problem?):
int numAccounts; Preferences prefs; prefs = Preferences.getPreferences(ctx); accounts = prefs.getAccounts(); numAccounts = accounts.length; Toast.makeText(ctx, "da num accts = " + numAccounts, Toast.LENGTH_SHORT).show(); .......... public class Preferences { private static Preferences preferences; SharedPreferences mSharedPreferences; private Preferences(Context context) { mSharedPreferences = context.getSharedPreferences ("AndroidMail.Main", Context.MODE_PRIVATE); } public static synchronized Preferences getPreferences(Context context) { if (preferences == null) { preferences = new Preferences(context); } return preferences; } /** * Returns an array of the accounts on the system. If no accounts are * registered the method returns an empty array. * * @return */ public Account[] getAccounts() { String accountUuids = mSharedPreferences.getString ("accountUuids", null); Log.i("westal", "prefs uuids = " + accountUuids); if (accountUuids == null || accountUuids.length() == 0) { return new Account[] {}; } String[] uuids = accountUuids.split(","); Account[] accounts = new Account[uuids.length]; for (int i = 0, length = uuids.length; i < length; i++) { accounts[i] = new Account(this, uuids[i]); } return accounts; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en