Localization Through Application Class?
<p>I am implementing localization example through an app. I used Application Class to update the selected language to entire application. The issue is when i change the language at the first time then it's changing to entire application. Again when i am trying to change the language then it's giving force close error.The error is at this line editor.putString("Language", getString(identifier)); Below is my code and logcat errors. I am not understanding how to fix this.</p>

<pre><code>    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {

        super.onListItemClick(l, v, position, id);

        TextView mTextView = (TextView) v.findViewById(android.R.id.text1);

        Toast.makeText(getActivity(), mTextView.getText().toString(), Toast.LENGTH_SHORT).show();

        int identifier = getResources().getIdentifier(
                mTextView.getText().toString(), "string",
                getActivity().getPackageName());

        String language = getString(identifier);
        Toast.makeText(getActivity().getApplicationContext(), language, Toast.LENGTH_SHORT).show();

            editor.clear();
            editor.putString("Language", getString(identifier));
            editor.commit();
            changeLanguage(getString(identifier));

    }   /**
     * Method to change the language
     * 
     * @param localString
     */
    public void changeLanguage(String localString) 
    {
        AllUpdateApplication.updateLanguage(getActivity().getApplicationContext());


    }

public class AllUpdateApplication extends Application{


    /**
     * Application wide language change
     * @param mContext
     */
    public static void updateLanguage( Context mContext){

        SharedPreferences mUWBTPRefs = mContext.getSharedPreferences("language", 0);
        String mLanguage = mUWBTPRefs.getString("Language", "en");
        //Toast.makeText(mContext,mLanguage, Toast.LENGTH_SHORT).show();
        Configuration mConfiguration = new Configuration();
        mConfiguration.locale = new Locale(mLanguage);
        mContext.getResources().updateConfiguration(mConfiguration, null);

    }
}


02-18 15:30:28.660: E/AndroidRuntime(6819): FATAL EXCEPTION: main
02-18 15:30:28.660: E/AndroidRuntime(6819): android.content.res.Resources$NotFoundException: String resource ID #0x0
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.content.res.Resources.getText(Resources.java:247)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.content.res.Resources.getString(Resources.java:331)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.support.v4.app.Fragment.getString(Fragment.java:593)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at com.uwbt.fragments.LanguagesFragment.onListItemClick(LanguagesFragment.java:89)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.widget.AdapterView.performItemClick(AdapterView.java:292)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.widget.AbsListView.onTouchEvent(AbsListView.java:3180)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.View.dispatchTouchEvent(View.java:5545)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1951)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1712)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1912)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1371)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.app.Activity.dispatchTouchEvent(Activity.java:2391)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1860)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.View.dispatchPointerEvent(View.java:5725)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2928)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2492)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:870)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2501)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.os.Looper.loop(Looper.java:137)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at android.app.ActivityThread.main(ActivityThread.java:4424)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at java.lang.reflect.Method.invokeNative(Native Method)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at java.lang.reflect.Method.invoke(Method.java:511)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-18 15:30:28.660: E/AndroidRuntime(6819):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
