Тёмный

How To Use an Existing SQLite Database with Xamarin and .NET MAUI 

Gerald Versluis
Подписаться 104 тыс.
Просмотров 16 тыс.
50% 1

Опубликовано:

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 101   
@jfversluis
@jfversluis 2 года назад
Want to learn more about SQLite? Check out this video on how to implement the CRUD actions: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-8_cqUvriwM8.html Or maybe you want to learn how to encrypt your database as well, that's in this video right here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-O1UQfoh4710.html
@johnchance5446
@johnchance5446 2 года назад
James Montemagno didn't cover this topic but you did. Thanks a lot. It would take me days or even weeks to figure out this very tricky Microsoft path issue.
@jfversluis
@jfversluis 2 года назад
Glad it was helpful to you! 😄 it’s the tricky stuff that make these videos helpful…
@alancamey4666
@alancamey4666 2 года назад
Thanks Gerald i follow you in the social network, i've tried to do implement many option and searching many solution but up to i was view exactly this video gave me the solution how i can to embebbed the data base, without using dba command because i would have many steps to get permission in my device but now don't need anymore that. Thanks for shared your knowledge you are very kind!
@fritzswitzer
@fritzswitzer 2 года назад
Gerald, Like your video and style. However, I'm having difficulty converting to a.NET Maui. I can get my code to find an existing SQLite db (MAUI Asset) located in the Project folder and it is connected and displays data in a Collection View for the Windows project. However, the problem is with the Android project. I can't find a good resource for where to place the existing sqlite db ,eg. "Resources"... and how to set the properties. A .NET Maui sample for existing sqlite db's would be a great assist for the devs, jumping into the Maui pool :) Thanks in advance.
@chezchezchezchez
@chezchezchezchez Год назад
You ever solve this issue? Thanks
@JackyTran
@JackyTran 5 месяцев назад
GG working on Maui.
@fabianuriarte2519
@fabianuriarte2519 4 месяца назад
Could you show how to automatically scaffold the entire database model? I noticed from FK relations in the SQlite file. Thank you for your videos.
@emilienrakotonoelina7153
@emilienrakotonoelina7153 5 месяцев назад
I insert data in the DB, but, after that if I restart emulator, the data inserted is not save in the database. What is the problème ?
@nuruliman8101
@nuruliman8101 7 месяцев назад
Love the tutorial, thank you so much. I hope you'll do more tutorial that can we learn and implement for our studies until it become one complete apps
@jfversluis
@jfversluis 7 месяцев назад
What do you still want to learn?
@liberty2four2
@liberty2four2 3 месяца назад
Hi Gerald, during 'Release/Publish', is the actual .db file will be included in the .ipa file?
@jfversluis
@jfversluis 3 месяца назад
It should be!
@benjamindlion7544
@benjamindlion7544 9 месяцев назад
I'm one of those who commented on your .Net Maui SQLite video and asked whether you could do this - I literally found this video about 10 minutes after posting the comment! So thank you - this is great! One thing is bothering me though. Does this actually make a second copy of the database on the target device? It feels like the dB is going to get downloaded to the target in wherever it's placed (in the root in the caseof this example), and then copied to the working target directory. Is that actually what happens or is there some sort of weird virtual mapping going on? My dB is 500K and it feels extravagant to have two copies of it! Thanks again - and I think the "EmbeddedResource" build option is what fixed this for me. I had seen someone else saying it should be "MauiAsset", but I just couldn't get that to work
@HerteldenVideolar2010
@HerteldenVideolar2010 2 года назад
İngilizce bilmiyorum ama yine de severek izliyorum. Teşekkürler.
@jfversluis
@jfversluis 2 года назад
Çok teşekkür ederim! Maalesef Türkçe bilmiyorum, umarım kod örnekleri yine de işe yarar :)
@Mielesplayz
@Mielesplayz Год назад
@@jfversluis Gotta love Google translate magic
@drmostafamahmoud1902
@drmostafamahmoud1902 2 года назад
Thank you for your effort. Thank you for accepting this request that I asked you a while ago.
@jfversluis
@jfversluis 2 года назад
My pleasure! Hope it’s useful!
@ArbazAbid
@ArbazAbid 2 года назад
Simple and to the point, thank you
@jfversluis
@jfversluis 2 года назад
Glad it was helpful! Thanks!
@user-ye7fo5mw7h
@user-ye7fo5mw7h Год назад
Hello Gerald. Thank you so much for this educational channel, I really learned a lot from you. My question relative to this video, how to replace mock address data in a class with data coming from sqlite
@jfversluis
@jfversluis Год назад
I’m not exactly sure what you mean. I have more videos on SQLite that will show you how to get data etc. Maybe that will help :)
@user-ye7fo5mw7h
@user-ye7fo5mw7h Год назад
@@jfversluis Thanks Gerald. I'll check that. Thanks for the great help you're giving to the subscribers.
@mashrulhaque1168
@mashrulhaque1168 2 года назад
Thank you so much Gerald.
@jfversluis
@jfversluis 2 года назад
You’re very welcome!
@deanbullen9021
@deanbullen9021 2 года назад
Thanks for this. You said the Main constructor isn't the right place to put that code, could you tell us where is? Also anything you can point me towards for the "TODO Only do this when app first runs" please?
@jfversluis
@jfversluis 2 года назад
It kind of depends on what you prefer. You probably want to do it somewhere in the App.xaml.cs which bootstraps your application. That's what I would be doing. And for the only when the app first runs you can either do some check on the database file if it is a new one or it has been edited, or you can use AppInfo APIs to determine if an app is ran for the first time or not: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-qr_5mwqTxY0.html
@Ejrr1085
@Ejrr1085 2 года назад
@@jfversluis That is not clear in AppInfo. And what happen when the app update, the database is copied again?
@InfiniteSolutionsDel
@InfiniteSolutionsDel 2 года назад
Hi Gerald Thanks for your fantastic videos. I have been following you and learning a lot about Xamarin forms and SQLite. I was earlier programming in C# and using SQLite on wince based systems. Now can you advice how to copy SQLite database from PC to android device and use it in xamarin forms . Also after updating the database I would like to copy the database back to PC
@jfversluis
@jfversluis 2 года назад
Thank you so much! Unfortunately, I don't know how much advice I can give you. I think I will need to know more specifics before being able to say something useful. That all sounds very possible though :)
@dhirenpathak
@dhirenpathak Год назад
Thanks for Video, Can you please help us how to sync data sqlite to Mysql or Sqlserver
@schulz5patrick
@schulz5patrick 2 года назад
Great video! Do you plan a video to Xamarin.Essentials.Launcher and how to set up an application that can be called with it by any chance?
@jfversluis
@jfversluis 2 года назад
Not yet, but I'll add it to my list and see what I can do :)
@anandshindey
@anandshindey 2 года назад
Thanks for the video. Its great. How about a video comparing sqlite vs realm?
@jfversluis
@jfversluis 2 года назад
Thanks! I’ll look into it
@charlykjoseph
@charlykjoseph 11 месяцев назад
any idea how to not remove the database when uninstalling and installing the new version by updating the old sqlite db
@rubenzabaladecos1326
@rubenzabaladecos1326 2 года назад
Hi! When you create the table of the DB, it is not a best option to wait to complate the execution? Like this: "_database.CreateTableAsync().Wait();"? Or it is not necesary and congrats for your videos!!!
@jfversluis
@jfversluis 2 года назад
.Wait is never a great option, you should use await wherever you can!
@Itn.2004
@Itn.2004 9 месяцев назад
I want to check if there is no .db3 file, then copy the .db3 file I provided. I want to do it in splash screen (written in project.android) so is there any way to do the test in the main project (project share source)? Thanks
@Agredo10
@Agredo10 2 года назад
You should take look at Entity Framework and Xamarin. Its incredible how easy it is. really! My absolut recommendation to use SQLite its amazing! And super simple about 5 Lines of Code!
@jfversluis
@jfversluis 2 года назад
What does Entity Framework add that is so valuable?
@Agredo10
@Agredo10 2 года назад
The mein benefit is to share and reuse code from Backend for example. We Have a Xamarin.forms App Solution containing our whole ASP.NET Core API Backend. In ASP we are using EF with all the models and so on. We can reuse them in the exact way we are using them in Backend for our local SQLite DB. There is simply no difference. Its simply not one more different way to use it and in addition with a bit more time its pretty simple to create migrations. Even simpler with MAUI (because it need .NET Standard 2.1 for minimum)
@chezchezchezchez
@chezchezchezchez 2 года назад
@@jfversluis What? How can you NOT know about the wonderful EF?
@jfversluis
@jfversluis 2 года назад
I know about it, just wondering what the added value would be in a mobile scenario :)
@matejl92
@matejl92 2 года назад
Great stuff. Planning any EF with Migrations video in the future?
@jfversluis
@jfversluis 2 года назад
Thank you! It seems a lot of people have interest in that, so let me see if I can prioritize that :)
@matejl92
@matejl92 2 года назад
@@jfversluis Cool! Looking forward to it. We did it at one of the projects recently in Xamarin.Forms and I would really like to see your approach. :)
@chezchezchezchez
@chezchezchezchez 2 года назад
@@jfversluis Please do!
@xayaLB
@xayaLB Год назад
hi Gerald, that video its very important for me, thank you, but I can't get the .db file to appear in my project, I dont know why....
@philippedoumet6073
@philippedoumet6073 2 года назад
Hello 👋 Do you recommend buying a macbook over a windows for a software engineer?
@jfversluis
@jfversluis 2 года назад
There is many factors that influence this so it’s hard to recommend anything. If you want to do something with iOS/macOS, get a Mac, you want to do something with Windows, get a windows machine. All the rest pretty much works on both machines.
@philippedoumet6073
@philippedoumet6073 2 года назад
@@jfversluis okay thanks👌🏻. It's between the razer blade 14 and the mac book pro 14...
@thorbenschott2481
@thorbenschott2481 Год назад
I Like your Maui-Content, it´s on the Spot. And with this I need some help. I´ve written all what you´ve told in a .net6 and in a .net7 Maui App and I can´t figure out why "stream" is null if I run this.
@JeromeHeiser
@JeromeHeiser Год назад
I have the same issue. Don't know if Gerald knows the answer. Have you made any headway on it?
@JeromeHeiser
@JeromeHeiser Год назад
Also it appears Gerald is developing on a Mac. I think like me you are developing on a Windows machine which could be part of the problem. It seems there is an underlying permission issue.
@jfversluis
@jfversluis Год назад
On Mac or Windows shouldn’t be different. Is this in Android and Android 13 specifically maybe?
@JeromeHeiser
@JeromeHeiser Год назад
I am getting an InvalidOperationException on the Stream read. Is this a permission problem? If so how do I set the permissions within the app to that it can be cross platform?
@RossWasTaken
@RossWasTaken 2 года назад
in maui I just get 'Object reference not set to an instance of an object.' stream was null
@iTrackBilliards-videos
@iTrackBilliards-videos Год назад
Question: I have (basically finished) Maui app that uses Sqlite. Is it possible to use that DB (and all my code) but still make use of Azure Mobile Apps to sync to a cloud db?
@jfversluis
@jfversluis Год назад
It seems to use SQLite! But not sure how it will integrate with your existing code: learn.microsoft.com/azure/developer/mobile-apps/azure-mobile-apps/quickstarts/maui/offline
@iTrackBilliards-videos
@iTrackBilliards-videos Год назад
@@jfversluis It looks like I would have had to start with Mobile Apps. It would be a rewrite to use it at this point. I'm writing my own sync code now. Thanks for the reply!
@Swarajcookingnfun
@Swarajcookingnfun 2 года назад
Hey Gerald!! In one of my MAUI Blazor project, Android Emulator is not in the list but Windows machine and also for all other projects I am able to debug using android emulator. What I need to change or update in that project to see Android emulator
@Swarajcookingnfun
@Swarajcookingnfun 2 года назад
It worked now by running this command in the PowerShell : dotnet workload install maui
@jfversluis
@jfversluis 2 года назад
Perfect, thanks for letting me know!
@kartikmehta4455
@kartikmehta4455 Год назад
Hi Gerald Thanks for your fantastic videos. I need help - I have existing SQLite database and want to update data and at the end of the day copy SQLite database to computer. I need your help to achieve this. Appreciate !! Thanks.
@chezchezchezchez
@chezchezchezchez Год назад
You ever solve this issue? Thanks
@TheErudito
@TheErudito 8 месяцев назад
And for net maui hybrid
@jfversluis
@jfversluis 8 месяцев назад
Should be mostly the same
@AMIRKHAN-dm2fm
@AMIRKHAN-dm2fm 2 года назад
hi is it possible to detect incoming phone call accept the call and play already exist recording or music .all thins should be done in background. I need just android
@jfversluis
@jfversluis 2 года назад
On Android you might be able to do that
@AMIRKHAN-dm2fm
@AMIRKHAN-dm2fm 2 года назад
@@jfversluis can you please share some docs or can i do this with Xamarin.Android
@joshuaambas70
@joshuaambas70 Год назад
How to find the .db file of sqlite in xamarin form? Thanks
@jfversluis
@jfversluis Год назад
Not sure what you’re asking. Either place it in a path you know when you deploy the app or let the user pick the location.
@SmartAzan
@SmartAzan 2 года назад
Can I use that with Xamarin.Android projects?
@jfversluis
@jfversluis 2 года назад
Absolutely! There is nothing specific about Forms here :)
@afsalc9674
@afsalc9674 2 года назад
how we can sync data between sqlite and rdms database? and sync between hive and document based database?
@jfversluis
@jfversluis 2 года назад
Syncing is always a problem and very specific to your needs and requirements there
@afsalc9674
@afsalc9674 2 года назад
@@jfversluis specific user datas only synced to device. what all transactions from device will synced to server rdbms. is there any way?
@jfversluis
@jfversluis 2 года назад
Sure, but you’ll have to build it yourself. There is nothing prebuilt for this that I know of
@afsalc9674
@afsalc9674 2 года назад
@@jfversluis what is dotmim.sync?
@jfversluis
@jfversluis 2 года назад
🤷‍♂️
@techtricks7084
@techtricks7084 2 года назад
I am here 😀
@jfversluis
@jfversluis 2 года назад
Glad you made it!
@Swarajcookingnfun
@Swarajcookingnfun 2 года назад
How we can read text file already stored in internal storage of android device using maui blazor android app?
@jfversluis
@jfversluis 2 года назад
You can use the .NET MAUI File System Helpers for that: docs.microsoft.com/xamarin/essentials/file-system-helpers#using-file-system-helpers
@Swarajcookingnfun
@Swarajcookingnfun 2 года назад
@@jfversluis Thanks ,
@Swarajcookingnfun
@Swarajcookingnfun 2 года назад
@@jfversluis I think there are lots of issues in Maui Blazor, but for Maui app everything works. That's why when I try to implement filesystem it's not able to read the file I created at /data/user/0/files location.
@jfversluis
@jfversluis 2 года назад
I have been building a .NET MAUI Blazor app perfectly fine tbh.
@Swarajcookingnfun
@Swarajcookingnfun 2 года назад
@@jfversluis I have a query like why Maui Blazor app is not creating by itself the package name folder in internal storage location of android device?
@MishaFlower
@MishaFlower 2 года назад
How do i display data from sql server?
@jfversluis
@jfversluis 2 года назад
You probably want to put an API in front of that SQL server and interact with that :)
@egonzalez5276
@egonzalez5276 2 года назад
Ok so while it does work i do have 2 problems that i cant wrap my brain around, 1. How to make a checkbox save its state (currently it just goes back to false) 2. How to make it so the searchbar actually works (yes both are on the same page using the video code as a base) Edit: did the second one using this ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-PvEAuGGZ_8o.html
@jfversluis
@jfversluis 2 года назад
This one shows an actual checkbox: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-8_cqUvriwM8.html
@egonzalez5276
@egonzalez5276 2 года назад
@@jfversluis had problems with the code since the one in the video is not async , getting error in the foreach part of the code when i change everything to async
@UzairAli001
@UzairAli001 Год назад
I'm getting this error "Access to the path '/data/user/0/com.companyname.myapp/files' is denied" on calling "File.WriteAllBytes(path, memoryStream.ToArray());"
@jfversluis
@jfversluis Год назад
Make sure that you have added the right permissions to your app!
@xayaLB
@xayaLB Год назад
Now I have this problem, System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.' public class BrandRepository { SQLiteConnection db; public static string DbPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) , "MyDataBase.db"); public BrandRepository() { db= new SQLiteConnection(DbPath); db.CreateTable(); } public List List() { return db.Table().ToList(); } } show exception in line db.CreateTable();
Далее
Highly Customizable Popups for .NET MAUI with Mopups
18:20
Mark Rober vs Dude Perfect- Ultimate Robot Battle
19:00