Accessing android res folder


#1

Hello.
I am making android app by android ant on OS X.
My environment:
OS X 10.11.4
JUCE 4.2

So, I want to access in res folder.
Because, I want to use large audio files that can’t have as a binary.

On JUCE project folder, there is res folder in /Application/JUCE/myJUCEprojects/“Project name”/Builds/Android/res .
On apk file, there is res folder in /“Project name”/res .

I tried File:getSpecialLocation.
But I can’t access res folder.
Maybe, on android machine, there is res folder in /data/app/com.“companyname”.“applicationname”/base.apk .
However, I don’t know way to access inside of the base.apk.

Do you have any solution?


#2

The apk is just a zip file so you can access it with JUCE’s ZipFile class.


#3

Thanks fabian!

Can I use inside of res folder by using ZipFile class on android machine(not on OS X)?


#4

I tried accessing res folder using ZipFile class.
But I can’t. I received wrong access log.
This is code.
Something wrong?

    void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override
    {
        File apkfile = File::getSpecialLocation(File::currentApplicationFile);
        ZipFile zip(apkfile);
        ScopedPointer audioFile(formatmanager.createReaderFor(zip.createStreamForEntry(*zip.getEntry("/res/raw/test.wav"))));
        if(audioFile != nullptr)
        {
            ScopedPointer audio = new AudioFormatReaderSource(audioFile, true);
            transportSource.setSource (audio);
            readerSource = audio.release();
            transportSource.start();
        }else{
            log = "wrong access";
        }
    }

#5

Hmmm try removing the leading / in your zip path