+ final String user=PreferenceManager.getDefaultSharedPreferences(context).getString("username", null);
+ final String password=PreferenceManager.getDefaultSharedPreferences(context).getString("password", null);
+ if(user == null || password == null)
+ return toNonNull(context.getString(user_or_password_not_set));
+
+ conn.setRequestProperty("Authorization", "Basic "+Base64.encodeToString(
+ (user+':'+password).getBytes(), Base64.NO_WRAP));