Reputation: 329
I am struggling with this problem. I do not know where to put my file so that it can be visible when installing the apk
char s1[10];
FILE *infile, *fopen();
infile = fopen("/data/data/com.example.hellojni/files/datain.txt","r");
if (NULL == infile)
{
return (*env)->NewStringUTF(env, "***can't find the file");
}
fgets(s1,9,infile);
return (*env)->NewStringUTF(env,s1 );
I have no idea where to put my datain.txt. I put it in the bin folder but it isn't working. I keep saying can't find the file. The path is correct because I print it out on my screen.
Help pls,
Thanks.
Upvotes: 2
Views: 241
Reputation: 137272
The most reliable approach I know about is:
First, in your Java code, store the file from your assets to some directory of the application, then pass the path of the file to the native function.
Upvotes: 1