We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2516

Summary: Extension: Auxiliary function to get the path to the Android APK file
Product: SDL Reporter: rettichschnidi <bugzillas>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: philipp.wiesemann
Version: HG 2.0   
Hardware: All   
OS: Android (All)   
Attachments: Add "const char * SDL_AndroidGetApkPath(void)"

Description rettichschnidi 2014-04-29 20:10:23 UTC
Created attachment 1637 [details]
Add "const char * SDL_AndroidGetApkPath(void)"

I am currently using PhysFS[1] for dealing with the OBB extension files[2], which are actually ZIP files.

Besides the Google Play version I also have to maintain a standalone version of my game which has its assets stored in the assets folder within the APK. In order to mount the APK file by PhysFS I need a way to retreive the path to the APK of the currently executed application.

The attached patch simply queries getPackageResourcePath[3] to achieve this.

1: https://icculus.org/physfs/
2: https://developer.android.com/google/play/expansion-files.html
3: https://developer.android.com/reference/android/content/ContextWrapper.html#getPackageResourcePath%28%29
Comment 1 Philipp Wiesemann 2014-04-30 21:32:59 UTC
There was an unused local variable "jobject fileObject" copied into the patch.

In bug 2258 a similar function was requested (hidden in obsolete) and briefly discussed. It was using getPackageCodePath() instead of getPackageResourcePath().
Comment 2 rettichschnidi 2014-06-22 00:33:04 UTC
True, it is easy to do it externally - I just thought that it would be convenient to have SDL sparing the dev dealing with the JNI API.

Given the low interest in something like this I will mark this ticket as resolved/invalid.