简体   繁体   中英

How to use a Database from a Windows tablet UWP app?

I will soon be deciding on a project for my university course and I had one in mind which is going to be a windows tablet application, using the UWP tools in Visual Studio, as I want to develop skills in C# and the Mobile area. However I will need to have a database behind my application to submit and retrieve data from. Is this a relatively "simple" and common task to do? I'm not looking for easy, I just want something that I can accomplish though without worrying too much over the basics.

My original thought was to have a database on my PC and then host it for my tablet to connect too, but that would require constant internet connection and for my PC to be hosting. After having done a little bit of research I came across something called SQLite, which people seem to think is a good local database to put into the device.

Having no experience with mobile applications though, I was curious as to how I would develop an application on my PC, and then put it onto the Windows Tablet, both using the same database? Would I need to duplicate the database between systems? Or would I write the code up on my PC and then test it on my Tablet?

Again this is an area i'm still new to, database 'hosting' and mobile applications. Maybe i'm just over thinking things, but just by asking the question I can already tell I sound clueless. My experience has been with small WPF applications, Console Applications and Websites.

I will need to have a database behind my application to submit and retrieve data from. Is this a relatively "simple" and common task to do?

I think the answer is yes. As you mentioned, SQLite is a good local database for you to use. Since there are guidance , samples , teach videos for SQlite with UWP, it should be simple and common task for you to do.

I was curious as to how I would develop an application on my PC, and then put it onto the Windows Tablet,

For this you need to Get started with Windows apps . After you finished developing the app on the PC, you can publish to windows store or Sideload your app package , then you can install the app on your tablet from store or through side loaded package.

Would I need to duplicate the database between systems?

The SQlite database is actually a database file with .db or other suffix saved on the local device. Whether need duplicate depend on where you put the database file on. Since UWP app is sandbox and have limitations for access the folder on the device. By default, all apps can access the following two locations, Application install directory and Application data locations . If you put the database file on Application install directory, once you install the app on one device, the database will exist on the install directory and you don't need copy. But this directory is read only means that if your database don't need update and read only you can use. For another location,Application data location there are LocalFolder , RoamingFolder and TemporaryFolder . If you put the database on LocalFolder it cannot be roamed and you need to manually copy or user a cloud server helper you save it for roaming.If you put the database on RoamingFolder it can roam pay attention it has some restrictions. More details please reference File access permissions . In my option, SQLite is a local database, which is using only for local data will be better, I don't recommend you to use it for roaming. If you need a roaming data base, a database on cloud or server side will be much better.

Having no experience with mobile applications though, I was curious as to how I would develop an application on my PC, and then put it onto the Windows Tablet, both using the same database?

You should get start from this document Intro to the Universal Windows Platform . I believe you'r familiar with C# language, you can use C# to develop UWP apps.

As you mentioned, you could use sqlite as local database in your app. You could use LiveSDk 's APIs to synchronous database when you switch from PC to tablet.

Here's a sqlite sample in uwp for your reference.

The OneDrive Photo Browser sample shows you how to get data from cloud, it would be helpful to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM