For those wondering why the "id" at 20:10 is 1 when it should be 2, it is because it is not the id that is returned - it is the number of rows affected, which is 1.
Wow, you can make a integration with a Azure DB ? I have 150$ on Azure monthly and I try to use it in a application but documentation is a little bit too complicated. Thank you very much! You are a legend 🎉
Great Video, but can you maybe answer me here or in private, where can I find the DB file on my PC/Andorid? I was trying to open it up and to see if my users that registered are saved on DB but I just can't find the file, I was using DB Browser (SQLite).
I'm having a rather strange issue. When I go to do something like CreateTableAsync, my app freezes. Debugging in VS2022 kind of goes crazy in that if I am stepping through the code and hit that line, I can no longer continue or keep stepping or anything. Any suggestions?
@@synergy.2899 I don't think I did. I ended up ditching SQLite for my project and just storing the data that I need in a JSON file since I'm not trying to store so much that SQL makes more sense anyway.
@@jeremybray8050 I was contemplating on doing the same thing as well. Its a shame because SQLite seems so nice but it doesnt seem like a lot of people had the same issue as us. Were you working with MAUI Blazor?
Awesome video! Can you also show how to now change databases using mvvm and similar services? Maybe discuss more on attributes? I was watching a mongodb c# video and attributes were used everywhere. (Maybe discuss entity framework) I love also how you are maintaining mvvm! I’m jumping into xamarin and your videos along with your other Best friends in the entire world have been illuminating!
James so much thanks about your videos you help us a lot! I have a suggestion, can you do a second part of some of your lessons with things for advanced. Here, for example, you can make an advanced video to show how to create a database with a script, how to update the tables with a script and some more complex queries.
Hey James great series so far that I've watched! I am having a nasty problem right now however. As i attempt to refresh and repopulate my items with the objects retrieved from the Sqlite database, the query itself will crash the app with a fatal signal 11. Everything in the DatabaseService class is copied from you apart from my own object class being used instead of your Coffee. I've been trying to figure out what's wrong with the database to no avail. What could cause this?
Great video! It follow the docs I have been reading on using SQLite with MAUI. However, can you provide guidenace on howto use an existing databese with the project ratrher than creating a database from scratch from code. I already have a database I want to use. Thanks in advnace.
Hello James, hope you can make more tutorials in SQLite CRUD. How to insert image in bytes and image file path. How to locate and manage the SQLite database using browser. If it is possible to retain your existing local SQLite database once the app has been reinstalled.
hey James, great video thanks for putting it out there. You did not mention the reason for the Task.Delay(2000) call in the Refresh() method. What is the benefit of having that call in there? Or, what would happen if there was no forced delay ?
Does your CoffeeService have to be s "static" class? I have a dynamic class (that gets injected) with a static DB instance (I couldn't figure out how to DI it, I kept getting errors). But now to a Windows target, it works fine but to an Android target I get SQLiteException, have you seen this behaviour before? Its a Xamarn App that was working fine, that I'm trying to move to MAUI.
First of all, Thank you for the great video! Btw, Am I the only one getting SQLite connection exception in the Init() function? I copied the code from the documentation. Can anybody tell me what can be the problem?
Hi. Net.maui application connect with local or remote server (mssql,mysql,postgresql) connect success on windows, macos and ios but android , it is not successfull. Please remote server connect with net.maui example video. Thanks.
Thanks for creating this video, great walkthough! Question though, I've always thought that it was bad practice to create 1 db connection and leave it open, especially in Xamarin where the app can be backgrounded etc. Is that still true, or am I mixing up sqlite-net and entity framework?
I was hoping to follow along from the last video (trying to code it from scratch with you)... but it seems you made a bunch of changes to the app in another video? I guess this playlist is not in the correct order? Going to try and piece this together from the github.
Awesome Video! Interesting to see you using a lazy loading technique for initializing your services. In my next application I will give that approach a try. :)
How do i pass picker to int then to service then lastly storing it to the database (ex. I want to pass picker id 1 type admin or id 2 type reguser but instead getting the type , get the id then pass it to the service and ultimately storing it to the database)
James, you're the man! Can't describe how much I appreciate absolutely amazing job you've done for Xamarin Community with a such great detailed videos. 🙃 p.s. Am I the only one who can't help himself but always shaking with head & shoulders to the rhytm of JM's intro music?😅
If anyone is getting stuck adding the SQLite file. Using the following solution (also by James) worked for me. var databasePath = Path.Combine(GetLocalFileDirectory(), "MyData.db"); db = new SQLiteAsyncConnection(databasePath); public string GetLocalFileDirectory() { var docFolder = FileSystem.AppDataDirectory var libFolder = Path.Combine(docFolder, "Databases"); if (!Directory.Exists(libFolder)) { Directory.CreateDirectory(libFolder); //
First time trying to store data from app into device and you made it a breeze. Been using some of your packages before, but just found this channel for the first time. Subscribed! Thank you!!
Thanks for yet another great video. You have shown at 21:05, when closed and relaunch the app, the coffee db still persists. I think that's because the app was still persist in the memory? because every time the app is launched, shouldn't the variable db be null? If it's null, then the db is recreated with the db.CreateTableAsync statements. Shouldn't that then wipe out what was in the db file?
Dear James, thanks for the nice video. In the Init task that you created, you put a if db exist then don't do anything if I understand well. In this same Init task you create the table "Coffee". My question is, if tommorrw I want to ceate a new table in the same DB, let say a "CoffeeMachine" table. If I understand well i create a new "CoffeeMachineService.cs", I create an Init task in it. But what I don't understand here is, when i will put the condition if db does exist don't do anything and I'm scared it will skip the creation of the table "CoffeeMachine" (because the Init of CoffeService.cs will have been already launch before and so the db already exist). Could you explain what I don't understand if you see what it is ? :-) thanks !
Hey James, tip for you in VS: If you press ctrl-c without selecting anything it copies the line, you can then paste the full line with the line break exactly where you want it. This seems to be fairly unknown, but saves a mountain of time for me. For example to duplicate a line just press ctrl-c and ctrl-v without selecting anything Thanks for the video.
Thanks a lot for a great video. How about making a video where you connect to an MS SQL server and authenticate with IdentityUser for Maui. I have not been able to find such a video yet. After all, users are usually authenticated against an online database. Thanks in advance.
Another great video James! Thanks. A few questions... are there any significant advantages of dealing with SQLite on such a low level? I have a production app with a fairly complex data model. To store the data offline I de/serialize the entire thing using Akavache (which uses SQLite under the hood). Everything works great, no issues at all. Akavache encapsulates all the wiring of tables internally. Same with your MonkeyCache, it's also awesome too I'm starting to use it as well. Question #2 - I'm curious... why do you say MonkeyCache/Akavache et. al. are "caches" only? Why can't they be persistent data stores?
I don't think any significant advantages or not. I just have always saved local data in SQLite over the years so I am used to it. MonkeyCache for sure is a cache layer and isn't intended to bused as a database. You can re-direct the file save location, but I intentionally put it in cache folder by default. I mostly use it for caching web requests and small bits of data. Akavache for sure is more like database as it is a key value store, but is persistent.
@@JamesMontemagno Thank you James. That makes perfect sense. BTW, I've stuck with Xamarin Forms since 2014. I wouldn't have done so without you and your awesome contributions to this platform. I appreciate it very much,
Nice tutorial! How can you automatically display the data upon going into the MyCofffee page (@21:10) from the database without pulling to refresh the page?
@@JamesMontemagno Thanks again for the tip! Much appreciate! Is this what you're referring to? I did it like so in the page code behind. private readonly MyCoffeeViewModel _model; public MyStoredCoffeePage() { InitializeComponent(); _model = BindingContext as MyCoffeeViewModel; } protected override async void OnAppearing() { base.OnAppearing(); await _model.Refresh(); }
How could you use an sqlite tool to view the contents of the database either directly on the emulator or by somehow copying it to the development computer?
There is a nice sqlite explorer for VS and VS Code that I have used for web stuff, but you would need to see where things are stored or export the database :)
Hi James! Thanks a lot for this video. I have a problem with my project and I'll like to ask for help on here. I am new to Xamarin and I have a project I'm currently working on where I have to connect my Xamarin app to a serverless backend. I have a signup page where users can register and when they hit a button, it automatically sends their information to my backend. The problem I have now is : How do I collect user inputs? I'm writing the API call to collect the data but I can't seem to get how to tell my program to take whatever is in this entry field (or entry fields), and send it over here. What I did so far was to give the entry fields a name so I can access it in the code behind as "entryField.Text". I tried to declare a variable and make it "entryField.Text" but I can't access the variable in my ViewModel and it also says an "unnecessary assignment". Please what am I doing wrong and how can I collect user inputs to use in my ViewModel and API call? I hope I can get someone to give suggestions on what to do.
Awesome video like everyone! Could you create one to show us how to sync this sqliteDB with an webdav drive that the app on an other device can use the same data as well.. so like some way how to sync the entries over the different devices in that app.
Thank you for the video. My question is: Suppose I have already an SQLite DB that I want to use as embedded resource, how I open it instead of creating it please?
You would just point it at the file location. I would probably take the resource and then copy it locally into the apps data directory and then just set the file location and boom data
Design question .... is it better to open your app to mainpage and then check the database if already logged in and then redirect to a login page if not? Or, start off at the login page and check database and then redirect to mainpage if logged in?
I am using this tutorial but I have noticed that when the application is launched with data in the SQLite DB you have to refresh. I have been tinkering with this and cannot seem to find what looks like the "proper" way you would have this DB data shown without the refresh on launch.
Hi James. I need to develop a employee directory but I'm having issues adding the existing database to display the employees. Can you please assist. Many thanks
Well, not sure what format your database is in, but you could write a small desktop app to convert it into the sqlite-net format that is needed and then drop it into your mobile app and read it with docs.microsoft.com/en-us/xamarin/essentials/file-system-helpers
@@JamesMontemagno thank you for your response. So basically I want to attach an existing table to my Xamarin app and have a search functionality. So I just needed help on adding an existing table to my Xamarin application. Thanks in advance
Followed your logic most of the way James, just got stuck in two places: 1) Consider your Coffee as my Operators. Where do I declare my GetOperators? public static async TaskGetOperators() 2) Secondly, var operators = new Operators { OpName = opName, OpPhone = opPhone, OpEmail = opEmail }; opName, opPhone and opEmail identify as errors. How can i fix that?
Where is "MyData.db" located in solution folder using file explorer? Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, "MyData.db") If it's not possible, where to find it once the app is installed in actual android phone device? Thank you James!
You can see where it this maps to here -> github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/FileSystem/FileSystem.android.cs which is inside of the app specific folder developer.android.com/training/data-storage/app-specific#internal-access-files
Ok, can you do a video on how to make use of an web API to connect a cross platform app to a SQL Server(EXPRESS) Database. Where a couple of users with their own devices can CRUD to the database from there mobile devices??
Love the tutorial. I'm having one issue, when I run the refresh command I get the error System.InvalidCastException: 'Specified cast is not valid.' I can't find anywhere where a variable type or anything wouldn't match so would appreciate any ideas as to what could be causing it. Thanks!
James, you're are a legend mate, I missed the U in your CRUD example, I followed along nicely but not sure how to change on of the values in a record, does SQLite even allow that?
Thanks for the video, James! I have been following your tutorial and at the point were I add a coffee to the data base it doesn’t appear after the refresh, the main page is just blank, any suggestions? Thanks! (timing of the problem 19:44)
Thank you Sir for your Tutorials are helpful and easy explanation way.. Really you are a good Teacher. I have a request, can you please make a tutorial About WPF with MVVM Design to build a App like in real life when creating a project?? And sure we would like you add your touch what best ways, and framework and deal with Database.
I don't really do much WPF work, but it is all the same. I would look at the documentation. For database stuff look at Entity Framework Core for you desktop apps.
I would assume possible if there is an api to call. Never done it. I would probably create a backend service that interfaces with your database. That is best practice
Great video. I'm curious if you are able to do this with dependency injection? If you are able to, what are the benefits of using a static class vs using DI?
Great video. Have to ask as I’m coming from another dev env: wouldn’t GUID be safer than an int id when many devices are sync’ing with one centralized server?
Excuse my interjection but this case is internal to the device; once you have sync with azure (say) that’s when guids are most useful, but if you start with the intention to sync you should probably start with guids:-)
Depends on your app and if you need the features of firebase and where you want your data to live. If you have all your data in firebase then that would be fine, but if the data is anywhere else then probably not
I'm new in XAMARIN and follow your videos and really you are awesome. I just need - is it possible to joins tables or write strored procedure or complex inline query in SQLite xamarin. I did not find such example anywhere.
Probably something like stackoverflow.com/questions/27260905/join-tables-in-sqlite-net-with-linq-on-xamarin-android-is-not-supported I don't think it has store procedures, it isn't a full like SQL database.
Great video as usual! Regarding performance, how does SQLite-net compare to EF Core? I use EF Core in my Xamarin apps and have some performance issues (mostly on Android).
EF Core is not optimized for mobile solutions due to reflection so I would probably not go that route unless you are building an internal enterprise app. That said I know the team is trying to improve this scenario in and around .NET 6
Simple and thorough. Thanks again, James. Could you please include how to connect your Xamarin App to an API server (JSON) in your upcoming videos? I need to share data from a SQL server used in house with the outside mobile app users.