SharedPreferences (on a null object reference)
<p>I try to add and get data using sharedPreferences, but I only receive this error in logcat:</p>

<pre><code>Attempt to invoke virtual method 'android.content.SharedPreferences
android.content.Context.getSharedPreferences(java.lang.String, int)'
on a null object reference
</code></pre>

<p>The line of code:</p>

<pre><code>public static final String PREFS_NAME = "MyPrefsFile";
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0); // &lt;-error here
</code></pre>

<p>I need create first the xml file? </p>