Languages

Menu
Sites
Language
Save file to device to access from device manager

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);
          }
}

Responses

1 Replies
bac

 

                    FILE* fptr = fopen("/opt/usr/media/Documents/test.txt", "w"); //this causes errors
 
The error caused is a persmission denied error.

 Use app_get_shared_data_path, or app_get_shared_resource_path to get the path to a folder that can be shared with other apps. In the device manager, this will be "/opt/user/apps/<your.app.name>/[data | resource]. Note that these are symlinks, and I have had problems with them in the device manager. Also, note permissions on the folder and files. But you should be able to pull or push using the device manager from there.

 

ken