I have a application \'A\' and application \'B\'.
Say, I have a string resource in the application \'A\'
<\\string name=\"abc\">ABCDEF<\\/s
It is possible! Take a look at the following code. It works for me.
public void testUseAndroidString() {
Context context = getContext();
Resources res = null;
try {
//I want to use the clear_activities string in Package com.android.settings
res = context.getPackageManager().getResourcesForApplication("com.android.settings");
int resourceId = res.getIdentifier("com.android.settings:string/clear_activities", null, null);
if(0 != resourceId) {
CharSequence s = context.getPackageManager().getText("com.android.settings", resourceId, null);
Log.i(VIEW_LOG_TAG, "resource=" + s);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
Hope this will help you.
It seems Ok. Here is my code
Resources res = null;
try {
res = getPackageManager().getResourcesForApplication("com.sjm.testres1");
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(null != res) {
int sId = res.getIdentifier("com.sjm.testres1:string/app_name1", null, null);
int dId = res.getIdentifier("com.sjm.testres1:drawable/card_1_big", null, null);
if(0 != dId) {
iv.setBackgroundDrawable(res.getDrawable(dId));
}
if(0 != sId) {
tv.setText(res.getString(sId));
}
}