Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Operations in Android NDK

I am using the Android NDK to make an application primarily in C for performance reasons, but it appears that file operations such as fopen do not work correctly in Android. Whenever I try to use these functions, the application crashes.

How do I create/write to a file with the Android NDK?

like image 971
RyanCheu Avatar asked Jan 02 '10 21:01

RyanCheu


People also ask

How do I open an NDK file?

You can open a file through the NDK using FILE and fopen , but don't forget to place a permission for it. In manifest developer.android.com/guide/topics/manifest/… Thanks, it works! And I also found out the updates on the manifest file will only take effect after you re-install the app.

What is the use of NDK in Android?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.

What is NDK and JNI?

JNI is just the way that Java handles calling into native/C++ code, and calling back into Java from there. It has nothing to say about Android - it is a Java language feature. The Android NDK is a way to write Android applications using code called by JNI.

What compiler does Android NDK use?

The NDK itself invokes a customized cross-compiler built on the arm-eabi-gcc compiler.


1 Answers

Other answers are correct. You can open a file through the NDK using FILE and fopen, but don't forget to place a permission for it.

In the Android manifest place:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  
like image 77
Ita Avatar answered Sep 28 '22 23:09

Ita