Showing error for MODE_PRIVATE within fragment in android
<p>Showing error while using MODE_PRIVATE for sharedPreferences within onCreateView</p>

<pre><code>    @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;
    }
</code></pre>