.NET MAUI & Storage, Part 3 - Where to save application data

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
do you want to know where to save your application data you should look at this video [Music] welcome to another.net maui episode this is the third one where i will talk about storage the first one was about secure storage the second one was about setting storage and today i will talk about where to save your application data because the different types of data should be saved at different places for example we have application data that are produced and that you want to be in backups when the operating system are backing up your device for example to icloud or via itunes but if you have cache data for example if you cache data from a server you don't want that to be in backups so i will show you where you can save different types of data in this video to demonstrate this i have built a very simple app where we will save a text to file so let's go to visual studio and into our view model and the method save note so first we need to figure out the path where to save this this is data created by the app and probably we want that the data to be inside of backups because if the user have problem with the device and need to restore it we want it to be there for them and that's the same on both ios and android so what we can do is that we can use this great class inside of maui called file system so file system so file system dot current dot update the directory and that is one we should use for saving data as you can see here we also have the cache directory and that one is what we should use when we have cache data or if we have data that we don't want to be inside of backups but for now we use app data directory so we want a full path including name so we want to we want the full path including name so create a variable full path is path dot combine i recommend you to always use path don't combine because it doesn't matter if you run on windows linux ios android it will work to combine path even if it should be backslash or flash that can be different between the operating system so use path don't combine like this path and then we have a file name my file dot txt for example and now we can go and write this to the disk file dot write all text and pause full path variable and string content that is this text property just like this okay we're done we can now save this to the file system to try to run it yes of course we should we set the breakpoint here restart that hello save yes we are inside the method we get the path that is light in the library and full path is with yeah this was not big enough so let's do like myfile.txt so we can combine them okay so now we have written it to the oop and everything is fine okay but if you have a database like sql lite or light db how can i apply this there yeah it is easy you should use this app data directory for saving your database unless it's about cache data because maybe you want to save cache data also in a database so then use cache data directory otherwise use app data redirectory it's not harder than that so this will be a very short video so thank you for watching subscribe to my channel there will be a lot more dotnet maui content see you next time
Info
Channel: Daniel Hindrikes
Views: 11,862
Rating: undefined out of 5
Keywords:
Id: 3xqIXS1SBaU
Channel Id: undefined
Length: 4min 46sec (286 seconds)
Published: Thu Aug 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.