I'm developing native app on Samsung Gear S2 which intended to record data from sensors (accelerometer) on device into local file system.
I try the directory ( /opt/usr/media/documents/text.txt
) but its not creating the file on device.
I have enabled the privilege: http://tizen.org/privilege/mediastorage. Code snippet below:
static char* write_file(const char* buf)
{
FILE *fp;
fp = fopen("/opt/usr/media/documents/text.txt","w");
fputs(buf,fp);
fclose(fp);
}
static void btn_write_cb(void *data, Evas_Object *obj, void *event_info)
{
appdata_s *ad = data;
buf="string to write";
write_file(buf);
}
What is the write way to do? OR Web app work for this task? Thanks
Finally I am able to write file in my Samsung Gear S2 Classic by Tizen Native App Development. With address: /opt/usr/media/text.txt. And used the privilege http://tizen.org/privilege/mediastorage. Here is my code snippet.
static void
app_get_data(const char *res_file_in, char *res_path_out, int res_path_max)
{
char *res_path = NULL;
res_path= "/opt/usr/media/";
if (res_path)
{
snprintf(res_path_out, res_path_max, "%s%s", res_path, res_file_in);
//free(res_path); //Disabling this statement works for me.
}
}
static char*
write_file(const char* filepath, const char* buf)
{
FILE *fp;
fp = fopen(filepath, "w");
fputs(buf, fp);
fclose(fp);
}
static void
btn_write_cb(void *data, Evas_Object *obj, void *event_info)
{
appdata_s *ad = data;
char *buf = NULL;
buf="Hello";
char filepath[PATH_MAX] = { 0, };
app_get_data("text.txt", filepath, PATH_MAX);
write_file(filepath, buf);
}