Read txt file in res/raw/ within Android NDK - android

I have a file within my application that I want to have included within the .apk for my android app that is a .txt file. My application is almost entirely written in C through the use of the NDK, using OpenGL as well. I know I can bundle the txt file by placing it in /res/raw/, but is there anyway I can access this within the android NDK?
-Thanks

See the native-audio sample in the NDK. This has code that reads from the assets folder.

Related

How can I use files in my Android application written in Rust?

I'd like to have additional assets shipped with my Android application, which I'm programming in Rust (using cargo apk from android-rs-glue).
How can I access a directory
with files which will be placed there during the installation
which is optimally local to the application (isn't there some "data" directory)
or achieve something similar where I can read a file (for example say a .obj file with some game models) without embedding these files into the source code
?

Android how to extract *.so file during execution

I have one android myLibrary.jar file. But myLibrary.jar file will load the native 3 different so file. I have a.so, b.so and c.so.
When i using in my own application, it just simply put the jar file to the Android Dependencies and all 3 so files put in the libs/armeabi of the main application package.
When deploy and install on the device, these so file will be in the data/data/my-appname/lib/*.so.
Now i need to provide the sdk solution. The user side doesn't want the main application. They just want the myLibrary.jar. So i am considering about packing all 3 *.so files to the jar. I searched for the how to add to the so files to myLibrary.jar. But i still don't understand.
In this following post:
[Ant]How to add .so file into a jar and use it within jar(set the java.library.path)?
It mentioned about adding the so file to the jar and extract at runtime. But i still don't understand how to achieve that.
After trying that mentioned in the following post:
Creating a product SDK: How do I add a native lib (.so) and a jar with the SDK I am creating?
After my sample application reference the the compiled jar that included the .so file. After installing to the device, the libs/armeabi/xxx is not unpacked on the install. So i would like to know how to extract them dynamically and save them to data/data/my-appname/lib/ so that i can use with System.loadlibary(.so).
Thanks a lot.

Using a linked file in Assets directory - FileNotFound Exception

I am trying to link to an external file from a shared repository between my iOS and Android apps. This does not present a problem for iOS, but it does for Android. My current solution is to create a copy of the file from the external repository and place it in my projects Assets folder. This solution works, but is not much of a good one in my opinion and involves too many extra steps.
Using Eclipse, I am able to link to a resource. It's as simple as copying a file into my Assets folder and being prompted to either copy the file or link to the resource. If I link to the resource and try to run my app, I get a FileNotFoundException. If I copy the file instead, the app file is found just fine.
Ideally, I'd like to link to the file so that when I pull a new update from git then I don't need to copy the file over every single time. I'd prefer to link to the file.
I don't know what Eclipse uses "under the covers" for "Link here" drag-and-drop stuff. However, it is an Eclipse-ism. Android's build tools are fairly isolated from Eclipse proper, and so they won't know about those links.
Using a hardlink, or perhaps a symlink, at the OS X filesystem level should work, as both Eclipse and Android's build tools should treat it like a local file.

How to set the path to the assets folder in Android NDK using Irrlicht Engine?

I want to know what is the path for the assets folder. I'm using Irrlicht Engine for render the graphics, and as you can see in the following code, I add a Folder File Archive to use the assets in the folder MyGameAssets that is located in the sd card directory.
//Create the irrlichtDevice
device = irr::createDevice(irr::video::EDT_OGLES1,
irr::core::dimension2d<irr::u32>(screenWidth, screenHeight), 32,
false, false, false, 0);
//With this path my Game can use the assets in the folder that is on SD card
device->getFileSystem()->addFolderFileArchive("/sdcard/myGameAssetsFolder/");
Whith those lines of code my Android Game works fine, but as I said before, I don't want to use the sdcard/MyGameAssetsFolder/. I want to use the Assets Folder of the Android Project. What could be the possible path? Is there any other solution in order to not to use the sdcard path?
I'm guessing you're following "Android NDK Beginner's Guide" Book tutorial. I am too! and I'm having the same issue you are having.
Seems there's no way pure Native C++ can access the asset folder inside the apk. You have to make your app JNI so with Java you can pass the asset folder path to C++.
But, it seems there's also a way to use the AAssetManager inside android native glue library but I don't know how because there is no documentation about, not even inside the docs folder inside NDK folder.

File sharing between android and opencv

I am trying to invoke opencv library from my android code.
I previously stored my haar xml under the /data/data/org.siprop.opencv/files/ directory and passed this file path (i.e. /data/data/org.siprop.opencv/files/haarcascade_frontalface_alt.xml) to the opencv library. This xml was successfully read by the opencv code.
But I noticed that these xml files were not packaged in the .apk file which meant I would have a problem when distributing the same.
I hence tried storing these haar xmls in the assets/files folder. Now the files were included in the .apk file but i could not locate this in the emulator via the DDMS file explorer. So not sure what file path can I pass back to the opencv library.
Can you please let me know where am i going wrong?

Categories

Resources