The following code works. Here take getting String resource for example.
1234567891011121314151617
publicvoidtestUseAndroidString(){Contextcontext=getContext();Resourcesres=null;try{//I want to use the clear_activities string in Package com.android.settingsres=context.getPackageManager().getResourcesForApplication("com.android.settings");intresourceId=res.getIdentifier("com.android.settings:string/clear_activities",null,null);if(0!=resourceId){CharSequences=context.getPackageManager().getText("com.android.settings",resourceId,null);Log.i(VIEW_LOG_TAG,"resource="+s);}}catch(NameNotFoundExceptione){e.printStackTrace();}}