 <p>if a sharedPreference doesn't exist a NullPointerException will be thrown, so I recommend you manage your code like this :</p> <pre><code>try { //handle the situation where there exists the shared preference } catch(NullPointerException exc) { //handle the situation of non-existent sharedpreference } </code></pre>