I am trying to use the correct class for storing data in my windows app. I used IsolatedStorageSettings on the Windows Phone app, but I need to use the Windows.Storage class in my Windows store App begin written with VS Express 2013
I need the data to remain secure on the device when the app is not in use and don't want it to be saved in the cloud or removed unless the use logs out of the app. SO it just need to stay secure while the user remains logged in regardless if they are using the app or its in the background or Windows shut it down for memory reasons.
I suspect roaming is not the way to go but which should I use: local or temporary?
OK, after some more research I found this.
http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
Looks like local app data is the correct method as temporary data can be removed by the device at any time. Roaming as it says is for data that you want to use across devices that is stored on OneDrive(old Skydrive).
And if someone needs the example code then here is the link for a simple example.
local
Data that exists on the current device and is backed up in the cloud.
roaming
Data that exists on all devices on which the user has installed the app.
temporary
Data that could be removed by the system at any time.
localcache
Persistent data that exists only on the current device.
Related
I'm a relatively new Developer building my first app.
Right now I'm in the process of developing a UWP app and I am needing to get the Hard Drive Serial number from the PC from the Views (OnNavigatedTo), then after a few more fields are filled out, to then save all values to a SQL Server.
What I have discovered up to this point:
Grabbing some values like Hard Drive SN are not so easy with UWP.
I don't seem to have access to Registry HKLM via UWP
I can grab it very easily with PowerShell, and write it to a JSON or XML file. which I plan to do with a Service Account when PC is imaged.
I Don't know where to put the file where the App can see it.
Writing to Sql Server can only be done by creating a webservice and making HTTP / JSON calls via App. (I have this part setup but have not started accessing it via app yet)
So the part I really need help with I guess, is Where to Put JSON/XML file that App will be able to see and read from. Unless of course, someone knows of another way to get Hard Drive SN into a UWP app.
Thanks for Any Help
The recommended way to do this (if you want to go to the Windows Store) is to use a FileOpenPicker and have the user choose the file manually.
If this is for side-loading only (not going to the Windows Store) you can write the file to the user's Documents folder and then the UWP can read it using documentsLibrary capability without any user intervention. You could also use a fullTrust extension to run the PowerShell script and to put the file in the app's data folder. You can check out the Desktop Bridge docs for more info on fullTrust extensions.
I have a Windows 10 universal app that is running on a Windows 10 Mobile device. I noticed from the Windows 10 Mobile device, it does have a file explorer but it limits you to only see certain "Known Folders" such as music, documents, downloads, etc... and that is all.
Furthermore, when I plug the device into my development machine via USB, I can browse the device but again, only the Known Folders above.
In my app, I am writing to a log file and that log file is stored to LocalStorage, under a folder for my app name, for example:
var dataPath = ApplicationData.Current.LocalFolder.Path;
I simply need to browse MY LOG FILE, that MY APP CREATES, in MY APP FOLDER. I read about a ton of, in my opinion hacks, to get access to this file/folder. For example, there are some third party applications that still mainly claim to target Windows Phone 8/8.1 but will still technically work for 10 such as:
Windows Phone Power Tools
Isolated storage spy
etc....
Then I also read articles on how to use a file in Pictures (or voice recording) and go to file properties to then gain access to the root or to create a root shortcut on the development machine and copy it to the mobile device, however, these are typically a year or more old and no longer work on my device (I suspect MS patched these hacks).
So, all that said, I would like to see a good way to access the root drive for development, or at least my app folder in the LocalFolder so I can access my files (such as logs or the sqlite db file). Maybe there is a way already but my google searches haven't turned anything up just yet.
Thanks!
As you've known, we can use some third party tools like IsoStoreSpy or Windows Phone Power Tools to access Isolated Storage. Although they are designed for Windows Phone 8 & 8.1, but they can also be used for Windows 10 Mobile. With these two tools, we can access LocalFolder, TemporaryFolder and RoamingFolder. For more info, see similar question: Accessing storage of simulator/device while debugging.
Besides these third party tools, there is also build-in support in Windows 10. We can use App File Explorer to view and manipulate files stored by your sideloaded apps. This is a new, cross-platform version of the Isolated Storage Explorer from Windows Phone 8.1. This tool should be able to work no matter your application is deployed in Debug mode or Release mode. But please note that this is a new tool added to Windows Device Portal in the Anniversary Update.
To use this feature, we must enable Device discovery and Device Portal. Then we can access application storage in web browser like following:
For more info, please see Device Portal for Mobile and Using the App File Explorer to see your app data. Also the similar question: Windows 10 Mobile: how can I see inside on my app folder? might be helpful.
I had a similar problem to solve few months back. I ended up doing two things:
I've implemented a 'Send Logs' button in settings that would upload logs to a ftp server. Actually it was a bit more than that, all installations of this app were managed by a central server and there was 'Get logs' button on the server side that would send request via push channel to the device to get the logs.
Got my hands on a Interop-unlocked device that I would use if the app was in a state that would make first option not possible.
I've stored some data in the ApplicationData.Current.RoamingSettings following the Example here http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh700362.aspx .
The problem is that after storing the data in the RoamingSettings and then removing the same data using ApplicationData.Current.RoamingSettings.Values.Remove(key) (I've checked and actually the data are no more there), if I Uninstall and re-install the App on my Phone the Data I've deleted are back in RoamingSettings...
I've tried also ApplicationData.Current.ClearAsync() that clean all but after uninstalling and re-installing the app same thing.. the data are back.
Any suggestions?
RoamingSettings are designed to work like that. They can be used to store settings between devices. After you uninstall the App from all devices, the settings would persist in the cloud for some time in case the User installs the App again. If you want to use only local data - take a look at LocalSettings.
You will find more information about Guidlines for Roaming Data here at MSDN.
And here at the blog you will find similar answer:
Q. What happens to roaming app data when an app is uninstalled?
A. As noted in the previous question, an app’s app data folders are removed from a device when the app is uninstalled. Roaming app data, however, persists in the cloud so long as the user has the same app installed on other devices. When the user uninstalls the app from all of his or her devices, roaming app data continues to persist in the cloud for a reasonable time (a matter of a few weeks) so that it’s still available if the user decides to reinstall the app within that time. Note that when you make a change to an app project in Microsoft Visual Studio and that change (such as changing the manifest) forces a full reinstall, app data is removed as part of the process. References: Guidelines for roaming app data(overview docs).
So your to remove permanently your RoamingSettings you will have to wait.
EDIT - thanks to Pablo we have more detailed information here at MSDN:
Roaming data for an app is available in the cloud as long as it is accessed by the user from some device within the required time interval. If the user does not run an app for longer than this time interval, its roaming data is removed from the cloud. If a user uninstalls an app, its roaming data isn't automatically removed from the cloud, it's preserved. If the user reinstalls the app within the time interval, the roaming data is synchronized from the cloud. The current policy specifies that this time interval is 30 days.
I'm creating a C# Metro/Modern UI app, and I need a way to handle some user data (mostly just small strings, but a fair amount of them), and specifically I'd like the data to 'roam' with a user's Microsoft Account. I know that you can handle this with roamingSettings, but it seems like that's supposed to be used more for like storing user IDs and other one-time settings, whereas I would be using it to store all of my app's data, and there seems to be a limit to the amount of space I get with that. I was thinking about using SkyDrive to host a "MyApp Data" folder, but I can't seem to figure out how to upload a simple text file to it :(
It seems like the best way to handle it would be to set up an account on Azure or EC2 and then make a simple PHP API so I could access the SQL database from my app, but I'd rather not have to pay for hosting.
I've seen other questions about Metro app storage on StackExchange and Microsoft's own forums, but most of those are in reference to local storage and using SQL servers to handle the storage.
So should I just use roamingSettings and keep an eye on the quota, should I try to use cloud hosting, or is there a better solution I just haven't thought of yet?
Thanks!
A few things about roaming settings:
- they are intended for that, settings. Not as a data replication scheme, thus the quota
- they are not immediate. You can create a setting named "highpriority" that will replicate in less than a minute, but other settings can take several minutes to replicate. If you need data to be available immediately, roaming settings are not an option. Also, if you exceed quota all your data will stop replicating, which is a bad thing. :) It also will not replicate between different versions of your app even if the settings are the same. In addition, if you do not use the app for a period of time (default is 30 days), then the roaming data will be deleted from the cloud. I am pretty sure roaming data can also be turned off via group policy in enterprise settings.
You can leverage SkyDrive. Make sure you download the Live SDK. Overview of using SkyDrive is here... http://msdn.microsoft.com/en-us/library/live/hh826521.aspx It is, fundamentally, just a collection of REST APIs. See the SkyDrive photo sample for an app that uploads files to SkyDrive http://code.msdn.microsoft.com/windowsapps/Live-SDK-Windows-Developer-8ad35141
I would go for a cloud based solution. A MS employee told me that the roaming data is a "best effort" there is no control if it actually works, sometimes it works, sometimes it just doesn't.
Personally I'd try to use the skydrive option
My problem is similar but not the same as that exhibited in:
"Could not find file" when using Isolated Storage
I've written an application that saves user settings in a file in isolated storage, I'm using the user store for assembly storage.
The application checks for a file in Isolated Storage on startup, and if it's not there assumes that it's the first time the application has been run and asks the user to configure it, this process then saves to Isolated Storage.
In Windows XP this works fine, I've not seen any issues whatsoever. However, I was running a demonstration to the client on their Windows Vista laptop and when I ran the client for the 2nd time to show that the settings were saved the application couldn't find the file.
Are there any known issues that might cause this to happen in Windows Vista and not Windows XP?
Both references to retrieve Isolated Storage are in the same .cs file, so it's definitely the same assembly that is making the call, and I didn't log in as another user, so I know it's the same user.
Isolated storage location will change as soon as you change the application version.
The proper place to store application configuration is in \ProgramData for all users and \Users\\AppData for user settings.