title: HashMap<String, Drawable> mDrawables;
body: <p>I'm trying to to key on the drawable ID to check if it is already available in memory before loading drawables again. I'm retrieving the theme from the theme apk package and retrieving them by String as seen in the getDrawable method. For the life of me I cant see why I get a nullpointer on this line and why it wont work.</p>
  
  <pre><code>"    if (!mDrawables.containsKey(name)) {"
  </code></pre>
  
  <p>This is how I'm calling it to display images in my Activities.</p>
  
  <pre><code>/* Custom theme */
          auxDrw = ThemeManager.getDrawable(ThemeID.FONDO);
          // Fondo
          if(auxDrw!=null)((LinearLayout)findViewById(R.id.about_layout)).setBackgroundDrawable(auxDrw);
  </code></pre>
  
  <p>This is the ThemeManager:</p>
  
  <pre><code>        public static Resources themeResources = null;
              public static String themePackage = null;
  
              public static void setTheme(Context ctx, String themePack){
                  PackageManager pm = ctx.getPackageManager();
                  themePackage = themePack;
                  themeResources = null;
                  try{
                      themeResources = pm.getResourcesForApplication(themePackage);
                  }catch(NameNotFoundException e){
                      Log.d("tag", "Theme not found: "+e.getMessage());
                  }
              }
  
          public static void setTheme(Context ctx){
                  String themePackageName = Utils.preferencias.getString("themePackageName", "");
                  ThemeManager.setTheme(ctx, themePackageName);
              }
  
  
          private static boolean mActive = true;
  
              private static HashMap&lt;String, Drawable&gt; mDrawables;
              private Context ctx;
  
  
          public ThemeManager(Context c) {
                      mDrawables = new HashMap&lt;String, Drawable&gt;();
                      ctx = c;
                  }
  
              public static Drawable getDrawable(String name) {
                  if (mActive) {
                      if (!mDrawables.containsKey(name)) {
                          try {
                              int resource_id = themeResources.getIdentifier(name,
                                      "drawable", themePackage);
                              if (resource_id != 0) {
                                  mDrawables.put(name,
                                          themeResources.getDrawable(resource_id));
                              }
                          } catch (NullPointerException e) {
                          }
                          return mDrawables.get(name);
                      }       
                  }
                  return null;
              }
  </code></pre>