Showing error for MODE_PRIVATE within fragment in android -


showing error while using mode_private sharedpreferences within oncreateview

    @override     public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {     view layout = inflater.inflate(r.layout.activity_package_categories, container, false);     sharedpreferences pref = getactivity().getsharedpreferences("packagetype", mode_private);     sharedpreferences.editor editor = pref.edit();     editor.putstring("package_categories_id", position);     editor.commit();     return layout;     } 

you should use context.mode_private.

 @override         public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {         view layout = inflater.inflate(r.layout.activity_package_categories, container, false);         sharedpreferences pref = getactivity().getsharedpreferences("packagetype", context.mode_private);         sharedpreferences.editor editor = pref.edit();         editor.putstring("package_categories_id", position);         editor.commit();         return layout;         } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -