[Solved] How to load a dictionary on android app start and use it from different activities


create application class and write this code in application class

public class MyApplictaion extends Application {
private static MyApplication myApplication = null;
public Map<String, String> fontDic;

@Override
public void onCreate() {
    super.onCreate();
    fontDic = new HashMap<String, String>();
    fontDic.put("1", "0x0627");
    fontDic.put("2", "0x0628");
    fontDic.put("3", "0x062A");
    fontDic.put("4", "0x062B");
}

public static MyApplication getInstance() {
    if (myApplication == null) {
        myApplication = new MyApplication();
    }
    return myApplication;
}

}

application class entry in manifest file

  <application
    android:name="com.example.app.MyApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

to use in activity

Map<String, String> fontDic=  MyApplication.getInstance().fontDic;

solved How to load a dictionary on android app start and use it from different activities