• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.app.Application;
4 import android.content.Context;
5 import android.content.SharedPreferences;
6 import android.preference.PreferenceManager;
7 import com.xtremelabs.robolectric.tester.android.content.TestSharedPreferences;
8 import com.xtremelabs.robolectric.internal.Implementation;
9 import com.xtremelabs.robolectric.internal.Implements;
10 
11 import static com.xtremelabs.robolectric.Robolectric.shadowOf;
12 
13 /**
14  * Shadow for {@code PreferenceManager} that returns instances of the {@link com.xtremelabs.robolectric.tester.android.content.TestSharedPreferences} utility class
15  */
16 @Implements(PreferenceManager.class)
17 public class ShadowPreferenceManager {
18 
19     @Implementation
getDefaultSharedPreferences(Context context)20     public static SharedPreferences getDefaultSharedPreferences(Context context) {
21         ShadowApplication shadowApplication = shadowOf((Application) context.getApplicationContext());
22         return new TestSharedPreferences(shadowApplication.getSharedPreferenceMap(), "__default__", Context.MODE_PRIVATE);
23     }
24 
25 }
26