我正在尝试使用Tizen Native Application将Gear S3的Heart Rate记录到一个简单的文本文件中。我能找到的唯一方法是使用Web应用程序......是否可以使用Native App?如果是这样,我在哪里可以找到参考文献?
非常感谢
答案 0 :(得分:1)
res 文件夹不允许在文件中写入文本,它只具有“读取”权限。因此,您应将其保存在具有读写权限的数据文件夹中。
char* get_write_filepath(char *filename)
{
char write_filepath[1000] = {0,};
char *resource_path = app_get_data_path(); // get the application data directory path
if(resource_path)
{
snprintf(write_filepath,1000,"%s%s",resource_path,filename);
free(resource_path);
}
return write_filepath;
}
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 = elm_entry_entry_get(ad->entry);
char *filepath;
filepath=get_write_filepath("text.txt"); // "text.txt" is file name
write_file(filepath,buf);
}
Evas_Object *write_btn = elm_button_add(ad->conform);
elm_object_text_set(write_btn,"Write");
evas_object_smart_callback_add(write_btn,"clicked",btn_write_cb,ad);
object_pack(box,btn,0.0,1.0,-1.0,1.0);
ad->entry = elm_entry_add(ad->conform);
elm_entry_scrollable_set(ad->entry,EINA_TRUE);
elm_object_part_text_set(ad->entry,"elm.guide","Write Text Here");
object_pack(box,ad->entry,1,1,-1,-1);
object_pack 是我的自定义函数,我将每个UI组件放在盒子容器中