Q:

The best way to hardcode arrays in your app?

My app needs three per-defiend arrays to run: an array of Strings and two arrays of integers. Each array has a length of 100. To add these arrays to my app, I thought of the following two approaches:

Hardcode them in a Utils.java class as a static final variables and reference them in my activities whenever I needed them.
Put them in the res folder and construct the array (using  getStringArray()) whenever I needed it.

Now, I am wondering:

What is the best approach in terms of Memory and efficiency?
Will the first approach increase the memory needed for my app? Will the second one causes delays and response issues?
Is there a better approach I should consider?

A:

If the arrays are the same for every language etc. I'd go with hardcoding in your Utils class. It's surely the fastest way, because if you have them as a resource, your app has to read the file at runtime which is way slower then having it in the code already.
The overall size of your app will not change much as with every method, you'll have the data somewhere in your app's package. Be it in code or in a textfile in the resources. Actually, as the hardcoded integers in code are stored binary as integers, they need slightly less memory (every integer in java requires 4 bytes to store, while an integer like 1000000000 in a textfile would require 10 bytes.
Only if those arrays were different for e.g. different languages, you should use the solution with resources.

