There is an application on Android written in Java using libraries written in C ++ using Android NDK. It is necessary that in one of the methods of the library C ++, while running the application , a file is created (in a particular directory). How can I do that? Or are there already ready methods?

Immediately I apologize if the question is not quite "correct".

    1 answer 1

    So what?

    FILE * ptrFile = fopen("file.txt", "w"); if (ptrFile != NULL) { fputs("Пример использования функции fopen ", ptrFile); // записать строку в файл fclose (ptrFile); } 
    • it is necessary that, for example, when using any function in an application, any information (logs are valid) be recorded in a file. Those. I'm on the smartphone after closing the application, open the corresponding directory, and there lies the created file. Your option creates a file and records information, but will this file be created anywhere on Android? - VadoM
    • @VadoM will be. The only question is which directory. - pavel
    • @pavel, do you know exactly how to specify the desired directory? For example, to create a file on a memory card. - VadoM
    • @VadoM I would recommend passing the file path to the function. You can of course use some sdcard/file.txt but it's safer to ask the android. - pavel
    • @sitev_ru needs, for example, when using any function in an application, any information (logs are valid) is recorded in a file. Those. I'm on the smartphone after closing the application, open the corresponding directory, and there lies the created file. Your option creates a file and records information, but will this file be created anywhere on Android? I duplicated the comment as the question remains open, and I thought you could help, but my previous answer wasn’t noticed) - VadoM