[Android] SDL_RWops

Hello, i tried to create a file on android by using SDL_RWops, however pointer to the file handle is null. What could be possible reasons of that or how to fix it?

Code:
SDL_RWops* file = SDL_RWFromFile(“file.txt”, “wb”);

Permissions that i use:

Code:

Assumes file working dir is android-project/assets.

You probably need to specify a full path, where you want the file to be
written. e.g. /tmp or SDL_AndroidGetInternalStoragePath()On Fri, Jun 20, 2014 at 11:21 PM, Flash wrote:

Hello, i tried to create a file on android by using SDL_RWops, however
pointer to the file handle is null. What could be possible reasons of that
or how to fix it?
Code: SDL_RWops* file = SDL_RWFromFile(“file.txt”, “wb”);

Permissions that i use:
Code:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

There is no problem with reading files that are included in .apk

Sam Lantinga wrote:

You probably need to specify a full path, where you want the file to be written. e.g. /tmp or SDL_AndroidGetInternalStoragePath()

Code:

sprintf(buffer, “%s/res/file.txt”, SDL_AndroidGetInternalStoragePath());
SDL_RWops* file = SDL_RWFromFile(buffer, “w+b”);
if (file == 0) Msg(SDL_GetError());

sprintf(buffer, "/tmp/res/file.txt");
file = SDL_RWFromFile(buffer, "w+b");
if (file == 0) Msg(SDL_GetError());

Result (logcat):

Code:
java.io.FileNotFoundException: /data/data/org.libsdl.app/files/res/file.txt
java.io.FileNotFoundException: /tmp/res/file.txt

You might also need to create the directories that you are trying to
access.(e.g. /data/data/org.libsdl.app/files/ and /data/data/org.libsdl.app/
files/res/).

Jonny DOn Mon, Jun 23, 2014 at 8:12 AM, Flash wrote:

There is no problem with reading files that are included in .apk

Sam Lantinga wrote: You probably need to specify a full path, where
you want the file to be written. e.g. /tmp or
SDL_AndroidGetInternalStoragePath()

Code:
sprintf(buffer, “%s/res/file.txt”, SDL_AndroidGetInternalStoragePath());
SDL_RWops* file = SDL_RWFromFile(buffer, “w+b”);
if (file == 0) Msg(SDL_GetError());

sprintf(buffer, “/tmp/res/file.txt”);
file = SDL_RWFromFile(buffer, “w+b”);
if (file == 0) Msg(SDL_GetError());

Result (logcat):
Code: java.io.FileNotFoundException:
/data/data/org.libsdl.app/files/res/file.txt
java.io.FileNotFoundException: /tmp/res/file.txt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Jonny D wrote:

You might also need to create the directories that you are trying to access.(e.g.??/data/data/org.libsdl.app/files/ and??/data/data/org.libsdl.app/files/res/).

What if i want to edit files that are included in .apk?
There’s no way to write in asset folder?

You can do that by locating the APK and accessing it as a zip file (e.g.
using zlib)… but don’t do that! Use the user’s data directory given by
something like SDL_AndroidGetInternalStoragePath(). Store and edit files
there.

Jonny DOn Mon, Jun 23, 2014 at 1:20 PM, Flash wrote:

Jonny D wrote: You might also need to create the directories that
you are trying to access.(e.g.? /data/data/org.libsdl.app/files/
and? /data/data/org.libsdl.app/files/res/).

What if i want to edit files that are included in .apk?
There’s no way to write in asset folder?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org