Вопрос

My main idea is to share resources between two applications. I'm using code below to get string item, but when I'm doing the same with string-array, it returns 0 always(it couldn't find resource):

String packageName = "com.example.mymainapp.mymodule.app.libs";
Resources res = getPackageManager().getResourcesForApplication(packageName);
int resourceId = res.getIdentifier(packageName + ":string/items", null, null);

I also tryed to do:

int resourceId = res.getIdentifier(packageName + ":array/items", null, null);

and

int resourceId = res.getIdentifier(packageName + ":string/items", "array", null);

and

int resourceId = res.getIdentifier("items", "array", null);

Appreciate any help.

Это было полезно?

Решение

This is the right variant, I was wrong some time before when got result from resId:

int resId = res.getIdentifier(packageName + ":array/items", null, null);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top