Files in Android

Files in Android
0.0 0


Hi everybody

My question is about files. I want to read a simple text file in mi app. Where I need to Add this file in my eclipse project?? Is just a single txt file, but i cannot figure where I need to put it, into my project, so FileOperation::readfile can ‘see’ it. Hope you can help me. Greetings!


Add file to your assets directory. It will be automatically packad to apk file.

For acces this file use:

    std::string textFileName = "file.txt";
        textFileName = CCFileUtils::fullPathFromRelativePath(textFileName.c_str());

    CCFileData data(textFileName.c_str(), "r");//r parametr depend on file type and operation -
    unsigned long nSize = data.getSize();
    unsigned char* pBuffer = data.getBuffer();