[ANDROID] Help needed to get size of a file

Hello,

I’m using the following code (found on internet) to get the size of a file, because i’m reading a text file with SDL_RWFromFile.
It’s working on Linux and Windows, but I can’t get the file size on Android.
I did some search on internet and get examples but it doesn’t work:

int get_file_size(string filename)
{
FILE *p_file = NULL;
p_file = fopen(filename.c_str(),“rb”);
fseek(p_file,0,SEEK_END);
int size = ftell(p_file);
fclose(p_file);
return size;
}

Main:

SDL_RWops* fileIN = SDL_RWFromFile( NomLecture.c_str(), “r+b” );
if( fileIN == NULL )
{
SDL_Log( “ERREUR Warning: Unable to open fileIN! SDL Error: %s\n”, SDL_GetError() ); //
}
else
{
unsigned char gDataLu[ InfoFileSize ];
SDL_RWread( fileIN, &gDataLu, ( sizeof ( unsigned char ) ), InfoFileSize );

SDL_RWclose( fileIN ); // Fermeture du fichier
} //

Could you please help me to get the size of file for reading it on Android?
Can we load the file without giving the filesize?
Thanks a lot for your help.

This works for me on all supported platforms (including Mac OS and Android):

long long size = SDL_RWseek (file, 0, RW_SEEK_END) ;

Richard.