I use the following code snippet in my application:
string_array = getResources().getStringArray(R.array.array_of_strings); my_text_view.setText(string_array[i]);
The problem is that I run an operation that contains this code many times. This way, I feel that this code is inefficient, since every time I run the operation, I need to load the whole array to just use one element specifically, since the array of strings is very large.
Is there a way to load the desired item directly?
Thank you very much in advance:)
update: I tried using the Application object as Talihawk listed below, but I get an error in the following line:
MyApplication my_obj = (MyApplication) getApplication(); string_array = my_obj.getStringArray();
Error:
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1047) android.app.ActivityThread.performLaunchActivity (ActivityThread.java:1615)
source share