Unable to use shared preference within a class that extends View
<p>I am getting an error , when I try to access the <code>shared preference</code> from within class that extends <code>View</code>.</p>

<p>The Error : "<code>The method getSharedPreferences(String, int) is undefined for the type ViewforRed</code>" ,</p>

<p>where ViewforRed is my class</p>

<p>Here is the sample code</p>

<pre><code> public class ViewforRed extends View

 {

       public final String PREFS_NAME = "GRAPHICS";
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);


           public ViewforRed(Context context)
             {
                super(context);

             }

         public void onDraw(Canvas canvas) 
               {


                 Paint paint = new Paint();

                 float  p0,p1,p2,p3,p4,p5,p6,p7,p8,p9;

   }

   }
</code></pre>
