java - Null Pointer Exception for Default Shared Preference Manager -


sometimes when call edit on default shared preferences, nullpointerexception. know why is? below code , error.

sharedpreferences sharedpreferencesfinish = preferencemanager.getdefaultsharedpreferences(getactivity()); sharedpreferences.editor spef = sharedpreferencesfinish.edit();   java.lang.nullpointerexception: attempt invoke virtual method        'java.lang.string android.content.context.getpackagename()' on null object reference 


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -