Code example for PackageManager

Methods: getResourcesForApplication

0
    /** 
     * Given a resource ID, returns the corresponding resource name or null if the package name / 
     * resource ID combination is invalid. 
     */ 
    private String getResourceNameById(String packageName, int resourceId) {
        try { 
            Resources resources = mPackageManager.getResourcesForApplication(packageName);
            return resources.getResourceName(resourceId);
        } catch (NameNotFoundException e) {
            return null; 
        } catch (NotFoundException e) {
            return null; 
        } 
    } 
 
    /** 
     * Scans all packages for directory content providers. 
     */ 
    public void scanAllPackages(boolean rescan) {
        if (rescan || !areTypeResourceIdsValid()) {
            getDbHelper().setProperty(PROPERTY_DIRECTORY_SCAN_COMPLETE, "0");