title: Mounting an encrypted obb apk expansion file in Android
body: <p>I have created an encrypted .obb file using the jobb tool. I use the following code to mount the obb file:</p>
  
  <pre><code>    public void mountExpansion() {
      final StorageManager storageManager  = (StorageManager) getContext()
          .getSystemService(Context.STORAGE_SERVICE);
  
  
      String packageName = "name.of.the.package";
      String filePath = Environment.getExternalStorageDirectory()
              + "/Android/obb/" + packageName + "/" + "main."
              + version + "." + packageName + ".obb";
      final File mainFile = new File(filePath);
      if (mainFile.exists()) {
          Log.d("STORAGE", "FILE: " + filePath + " Exists");
      } else {
          Log.d("STORAGE", "FILE: " + filePath + " DOESNT EXIST");
      }
  
      String key = "thisIsMyPassword";
      if (!storageManager.isObbMounted(mainFile.getAbsolutePath())) {
          if (mainFile.exists()) {
              if(storageManager.mountObb(mainFile.getAbsolutePath(), key,
                      new OnObbStateChangeListener() {
                          @Override
                          public void onObbStateChange(String path, int state) {
                              super.onObbStateChange(path, state);
                              Log.d("PATH = ",path);
                              Log.d("STATE = ", state+"");
                              expansionFilePath = storageManager.getMountedObbPath(path);
                              if (state == OnObbStateChangeListener.MOUNTED) {
                                  expansionFilePath = storageManager
                                          .getMountedObbPath(path);
                                  Log.d("STORAGE","--&gt;MOUNTED");
                              } 
                              else {
                                  Log.d("##", "Path: " + path + "; state: " + state);
                              }
                          }
                      }))
              {
                  Log.d("STORAGE_MNT","SUCCESSFULLY QUEUED");
              }
              else
              {
                  Log.d("STORAGE_MNT","FAILED");
              }
  
          } else {
              Log.d("STORAGE", "Patch file not found");
          }
      }
  
  
  
  }
  </code></pre>
  
  <p>I am getting the following output:
  <em>FILE: filePath Exists
  SUCCESSFULLY QUEUED</em></p>
  
  <p>But nothing inside <em>onObbStateChangeListener</em> is getting called. I am calling this function from a custom view and testing this on Nexus 4/ KitKat.</p>
  
  <p>What could be the reason for this behaviour?</p>