Save file to device to access from device manager

Save file to device to access from device manager

BY 07 Mar 2021 Native Application Development

I am using the sensors to store accelerometer data into an array. This works fine. Once I hit 10 updates I want to save the array to a log txt file to access from my PC in device manager (just as a test). I am using tizen native 4.0 on a gear s3. When I use get_data_path it returns:

/opt/usr/home/owner/apps_rw/org.example.get_accel_data_log/data/

However this is not visible from device manager. If I try to save it to media (I have given permission to save to media in manifest) I get errors. How can I just save a text file and access it from device manager? Is it because I am doing it from accell callback function??? I’m so confused

 

The complete code:

accelerometer_callback(sensor_h sensor, sensor_event_s *event, void *data)
{
          appdata_s *ad = (appdata_s*)data;
 
          if (ad->i == 1) {
                    ad->start_t = event->timestamp;
          }
 
          ad->test[ad->i][0] = (event->timestamp) – (ad->start_t);
          ad->test[ad->i][1] = event->values[0];
          ad->test[ad->i][2] = event->values[1];
          ad->test[ad->i][3] = event->values[2];
          ad->i++;
 
          char* test = app_get_data_path(); //cant access this from pc
 
          if (ad->i == 10) {
                    FILE* fptr = fopen(“/opt/usr/media/Documents/test.txt”, “w”); //this causes errors
                    fprintf(fptr, “test”);
                    fclose(fptr);
          }
}
Written by