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
Post a Comment