我的漫游数据在设备之间不同步 [英] my roaming data dosen't sync between devices

查看:40
本文介绍了我的漫游数据在设备之间不同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个 UWP 应用程序.我使用漫游数据.我通过这个保存设置:

I made a UWP application. I use the roamingdata.I save the setting by this:

public static void WriteCode(string pwd)
{
   ApplicationDataContainer RoamingSettings = ApplicationData.Current.RoamingSettings;
   RoamingSettings.Values["Code"] = EncryptHelper.PwdEncrypt(pwd);
}

我通过这个阅读了设置:

I read the setting by this:

 public static string GetCode()
    {
        ApplicationDataContainer RoamingSettings = ApplicationData.Current.RoamingSettings;
        string str = (String)RoamingSettings.Values["Code"];
        if (!String.IsNullOrEmpty(str))
            return str;
        else
            return EncryptHelper.PwdEncrypt("123");
    }

我完成了申请并上传到 Windows 商店并通过了检查.然后我在手机上下载了这个应用程序.

I complete the application and upload to windows store and passed check. Then I download this app on my phone.

我更改了手机上的 ApplicationData.Current.RoamingSettings.我向手机上的 ApplicationData.Current.RoamingFolder 写了一些东西.

I change the ApplicationData.Current.RoamingSettings on phone. I write something to the ApplicationData.Current.RoamingFolder on my phone.

接下来,我关闭了手机上的应用程序并在我的 PC 上下载了该应用程序.但是当我在我的 PC 上打开应用程序时,我发现 ApplicationData.Current.RoamingSettings 和 ApplicationData.Current.RoamingFolder 没有改变任何东西.

Next I closed the app on my phone and download the app on my PC. But when I opened the app on my PC, I found that the ApplicationData.Current.RoamingSettings and the ApplicationData.Current.RoamingFolder didn't change anything.

我在我的电脑上检查了 C:\Users\XXX\AppData\Local\Packages\XXX\RoamingState,什么都没有.我在我的电脑上检查了 C:\Users\XXX\AppData\Local\Packages\XX\Settings,有 roaming.lock 和 settings.dat.但是我无法再读取我在手机上添加的最新设置和漫游数据.

I checked the C:\Users\XXX\AppData\Local\Packages\XXX\RoamingState on my PC,there was nothing. I checked C:\Users\XXX\AppData\Local\Packages\XX\Settings on my PC,there was roaming.lock and settings.dat. But I can't read the lastest settings and roaming data that I haved added on my phone anymore.

我已经等了 2 个小时,我的电脑没有任何变化.

I have waited for 2 hours, there was no change on my PC.

有件事我应该先声明:

   1 All the deploy work was done by windows store.

   2 I check my PC application setting after closed the app on phone. I even shut down my mobile phone to observe the change to my PC. 

我的代码有什么问题?或者漫游数据机制有什么问题?我需要一个答案,谢谢!

what's wrong with my code? or what's wrong with the roamingdata mechanism? I need an answer, thank you!

推荐答案

您发布的代码是正确的.但是,漫游数据同步失败的原因可能有以下几种:

The code you've posted is right. However, there are some possible reasons for the failure of roaming data sync:

任何用户如果使用 Microsoft 帐户登录其设备,都可以从漫游应用数据中受益.但是,用户和组策略管理员可以随时关闭设备上的漫游应用数据.如果用户选择不使用 Microsoft 帐户或禁用漫游数据功能,她仍然可以使用您的应用,但应用数据对于每台设备都是本地的.

Any user can benefit from roaming app data if they use a Microsoft account to log on to their device. However, users and group policy administrators can switch off roaming app data on a device at any time. If a user chooses not to use a Microsoft account or disables roaming data capabilities, she will still be able to use your app, but app data be local to each device.

请记住,漫游数据与用户的 Microsoft 帐户相关联.只有当用户使用同一个 Microsoft 帐户登录其设备并在多台设备上安装该应用程序时,漫游数据才会同步.

Keep in mind that roaming data is associated with a user's Microsoft account. Roaming data will only sync if a user logs into her devices using the same Microsoft account and installs the app on several devices.

不要对依赖即时同步的数据使用漫游.Windows 不保证即时同步;如果用户离线或在高延迟网络上,漫游可能会显着延迟.

Don't use roaming for data that relies on instant syncing. Windows doesn't guarantee an instant sync; roaming could be significantly delayed if a user is offline or on a high latency network.

设置漫游不是即时的.系统在确定何时发送数据时会权衡几个因素.我们可以通过侦听 ApplicationData.DataChanged 事件.当应用程序数据刚刚完成从云同步时发生此事件.每当设备接收到新的漫游数据时,都会触发 DataChanged 事件,并传入更新的 ApplicationData 对象.这让我们可以在数据发生变化时对我们的应用进行任何调整.

Roaming of settings is not instant. The system weighs several factors when determining when to send the data. We can detect whether new roaming data has arrived on the local device by listening for the ApplicationData.DataChanged event. This event occurs when app data has just finished syncing from the cloud. Any time a device receives new roaming data, the DataChanged event will fire, passing in the updated ApplicationData object. This lets us make any adjustments to our app when data has changed.

对于重要的时间关键设置,请使用与 RoamingSettings 如下所示:

For important, time critical settings, use the HighPriority setting associated with RoamingSettings like following:

// High Priority setting, for example, last page position in book reader app
roamingSettings.values["HighPriority"] = "65";

这是漫游设置中的一个特殊键,我们可以用于需要立即同步的数据.将 HighPriority 添加到任何设置将使其尽快同步.

This is a special key in the roaming settings we can use for data we need to sync immediately. Adding HighPriority to any setting will have it synced as quickly as possible.

不要漫游大量应用数据.应用程序可以漫游的应用程序数据量是有限制的;使用 RoamingStorageQuota 属性来获得此最大值.如果应用达到此限制,则在应用数据存储的大小不再超过限制之前,任何数据都无法漫游.

Don't roam large sets of app data. There's a limit to the amount of app data an app may roam; use RoamingStorageQuota property to get this maximum. If an app hits this limit, no data can roam until the size of the app data store no longer exceeds the limit.

每个设置的名称长度最多为 255 个字符.每个设置的大小最多为 8K 字节,每个复合设置的大小最多为 64K 字节.同步引擎可能会限制可以漫游的设置和文件的总大小.跟踪您尝试漫游的数据量非常重要.如果您尝试同步的数据总量超过限制,则设备之间不会同步任何内容.

The name of each setting can be 255 characters in length at most. Each setting can be up to 8K bytes in size and each composite setting can be up to 64K bytes in size. The sync engine may limit the total size of settings and files that can roam. It’s important to keep track of the amount of data you’re attempting to roam. If the total amount of data you’re attempting to sync exceeds the limit, then nothing will sync between the devices.

应用数据仅在具有相同版本号的已安装应用之间漫游.例如,版本 2 上的设备将在彼此之间传输数据,版本 3 上的设备将执行相同的操作,但运行版本 2 的设备和运行版本 3 的设备之间不会发生漫游.其他设备上的版本号,新安装的应用会同步与最高版本号关联的应用数据.

App data only roams between installed apps with the same version number. For example, devices on version 2 will transition data between each other and devices on version 3 will do the same, but no roaming will occur between a device running version 2 and a device running version 3. If you install a new app that utilized various version numbers on other devices, the newly installed app will sync the app data associated with the highest version number.

如果您在漫游日期使用版本控制,请确保您使用的是正确的版本.

If you are using versioning in your roaming date, please make sure you are dealing with the right version.

这些是可能导致漫游数据在设备之间不同步的一些可能原因.有关详细信息,请查看 存储和检索设置和其他应用数据.

These are some possible reasons that can cause roaming data doesn't sync between devices. For more info, please check Roaming data in Store and retrieve settings and other app data.

这篇关于我的漫游数据在设备之间不同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆