1

I am developing an Android game using the Android NDK.

As for all apps weighing over 50mb, an expansion file is necessary. I have implemented the downloading of the expansion file and checking that it exists. I now need to read from a file within the .obb file. How do I do this on the native (C++) side?

Mark Nguyen
  • 7,168
  • 9
  • 31
  • 41
  • This might help... http://horribile.blogspot.com/2011/12/how-to-use-raw-resource-files-in-native.html I have yet to make it this far yet but it seems like a pain in the butt. I know they started limiting the ability for apps to write directly to the SDCard (controlled by manufacturer) but isn't there a way you could DL to the Data cache or something. Avoid the extra overhead of the obb file? – Jackie Jul 22 '13 at 15:40
  • Thanks for the link and suggestions. The main benefit of using the obb file is that it is securely (hopefully) hosted on the play store. If this isn't possible then downloading the individual assets to the data cache may be the only option – Mark Nguyen Jul 22 '13 at 15:51

1 Answers1

1

Check out <android/storage_manager.h> - there are functions for mounting, unmounting, and getting the path of your obb file:

/**
 * Attempts to mount an OBB file. This is an asynchronous operation.
 */
void AStorageManager_mountObb(AStorageManager* mgr, const char* filename, const char* key,
    AStorageManager_obbCallbackFunc cb, void* data);

/**
 * Attempts to unmount an OBB file. This is an asynchronous operation.
 */
void AStorageManager_unmountObb(AStorageManager* mgr, const char* filename, const int force,
    AStorageManager_obbCallbackFunc cb, void* data);

/**
 * Check whether an OBB is mounted.
 */
int AStorageManager_isObbMounted(AStorageManager* mgr, const char* filename);

/**
 * Get the mounted path for an OBB.
 */
const char* AStorageManager_getMountedObbPath(AStorageManager* mgr, const char* filename);

Then you should be able to manipulate files as you normally would.

krsteeve
  • 1,794
  • 4
  • 19
  • 29