How to get started with Windows Phone database programming - c#

I am really new to Windows Phone ( and Windows) development, and C#.I have done my first program as a unit convertor for Window Phone 8.1 using C# and Silverlight, run it on emulator and Phone both.
Now I want to build an application that can store data (e.g. a diary, that I can store plain text in it daily), something like usage of database, but I really have no idea how to do it and whether I need some sort of database, like SQLite, or there is some built in solution to store custom data in Windows Phone itself.
Can you please tell me how to and where to start?

In Windows Phone Silverlight apps, you have the option of using a SQLCE database with the LINQ-to-SQL framework on top of it (see docs here). If you're considering building a universal app that will run on both Windows and Windows Phone, however, your only database option is SQLite (see here for more details).
That said - unless you need to perform queries across a large amount of structured data, a database is probably overkill for your app. You may want to consider simply using flat files (docs here) to start and only upgrading to a database if the amount of metadata for the diary entries grows beyond what you'd want to keep in memory.

Related

Database connection with c# computer program and java android application

Ok im working on something and i have one question if this is even possible. I am doing 2 applications. One will be on the computer and the other will be on android device. On the computer user will input some data that will be stored in the database. The database will be local at my computer. Is there anyway that i connect to the same database with my mobile phone if it is on the same wifi, and store some information to that database from the mobile phone?
And what should i use? sqllite or MySql. Is it better to write the android application in java or in c# with the xamarine?
Thank you
Is there anyway that i connect to the same database with my mobile phone if it is on the same wifi, and store some information to that database from the mobile phone?
Yes it is. If database is available trough the network you can establish the connection.
Depends on what you're trying to accomplish, I would rather create the data service (using WCF for example) that would expose interface for both desktop and android applications. In this way you will have unified model for working with database. But you can work with database directly as well. There should be plenty of example of how to do that.
sqllite or MySql
You can work with any of them, it is more task specific then technology specific question. IMO, SqlLite might be a bit easier to use though
Is it better to write the android application in java or in c# with the xamarine?
Doesn't really matter. I would say if there is no specific reason why you want to chose xamarin, go with java.
There is wide range of posibilities. You can use SQL, NoSQL, plain text.. whatever you want. Xamarin Forms can be a good starting point especially using MVVM. With the same logic you can code both the desktop app and the mobile app. Try Catalog, http://catdb.eu. It does the same as you trying to achive.
For Xamarin.Forms there is a good reference book. It is pretty good. https://developer.xamarin.com/guides/xamarin-forms/creating-mobile-apps-xamarin-forms/

Connectivity with DB for Window store using Blank app template

I am trying to make a quiz application for Windows Store using the blank app template (in VS2013). I have the UI laid out in XAML but I don't know how to fetch Questions saved in my DB (MS access or SQL).
I have tried to find tutorials related to it,but what I have found is for WPF and Windows Forms. I had chosen the Blank app template, so can anyone explain how to fetch question from the Database in an application using Blank app template?
As it turns out, there's a good reason you couldn't find a tutorial for accessing a local DB in the WinRT environment. You can't. Microsoft didn't even include the requistite ADO.NET assemblies, assuming you could get out of the sandbox in order to connect.
There is a SQLLite project for Windows Store apps, found here. That's about as good as you can get it right now in terms of a local relational database in a windows store app.
What Microsoft intended for you to do was to store your database in the cloud (and if they have their way, on Microsoft Azure) and access it using a web service. Support for that is all over the WinRT API. It sounds like thats probably what you want anyways (unless you expect your users to generate their own questions) so I would go into that route.
A starting point for that would be to use Azure Mobile Services.
One last thing to note, WPF and WinForms are not WinRT, but there are other project templates (like the Hub template) that are. The fact that you chose the "Blank" template doesn't really affect anything in this regard.

How to get WP7-style ANID on Windows Phone 8?

I have a Windows Phone 7 app which relies on ANID to store user data on remote server. Now I'm preparing Windows Phone 8 version of it. When user will download this update previous WP7 app version will be replaced by this new WP8 version.
But there is a huge problem: in WP8 there is ANID2 instead of ANID. I know how to translate ANID to ANID2 (Windows Phone ANID to ANID2 conversion on C#?). But I need the whole ANID for this.
In WP7 ANID looks like: "A=2E23ACF364795673CD7EBB58FFFFFFFF&E=f48&W=3". I extract 32-character value (2E23ACF364795673CD7EBB58FFFFFFFF) and use it as UID (I heard that remaining portion may be changed, but 32 id will always be the same).
So I might convert ANID from WP7 version to ANID2 on-the-fly on remote server, but I don't have all 44 letters - only 32 of them.
I might update WP7 version with another WP7 version which sends the whole ANID to server, but I can't rely on the fact that all people will update their apps, save their data to server and then again update their apps when wp8 version will be available.
So my questions are:
is there any way to get WP7-style ANID value in WP8 app (maybe via reflection or c++)?
it is possible convert ANID to ANID2 having only its 32-character uid portion?
is there any way to find out whether particular ANID2 corresponds to existing 32-character ANID portion?
how can I reverse convert ANID2 to ANID if we know developer GUID?
can user select the version to install (if WP7 and WP8 versions available)?
Update
So far my workaround is to give users of wp8 version wp7 utility tool which generates ANID2 from ANID and stores this pair to remote database. Then user who gets wp8 version update can continue using his wp7 app profile.
Though I'm still looking for the better solution.
Btw, I've just realized: while we're trying to follow MSFT "One Screen" ideology and trying to provide our users access to their data on all MSFT devices at once, it's really stupid that MSFT makes us hold and somehow synchronize three (!!!) different ids for one user who log into his wp7, wp8 and windows 8 devices with the same live id! MSFT don't want us to see this live id so much that gives us its three different anonimized representations. Ridiculous, folks!
The only way is descrtibed in the question: publishing hidden utility with a link to it in wp8 version of main app. Utility itself is a wp7 binary which can access ANID and using dev GUID can generate ANID2. It sends both values to the server, and whn user comes with ANID2 server check dictionary and found corresponding ANID. Not that simple but quite easy. Hope it helps someone.
I would use a GUID i create the first time you startup the application, store that in isolated storage and use that. It won't cover the uninstall/reinstall scenario but that's a real small percentage anyway.
btw, the user will only get the latest version from the store so he/she cannot choose an older version (WP7 phones will only get the wp7 version ofcourse but wp8 users will always get the latest version from the store)
This might sound a bit naive and probably you would have already thought about it, and yes this is only an answer to your core issue, Is it possible for the windows phone 8 apps alone to point to the ANID2 implementation, maybe another remote end point, for some time till MS themselves kill the earlier(WP7) platform :)

C# Windows 8.1 app hide settings and data from user

I'm building a Windows Store app with C#, and I have certain data and settings that I need to persist between sessions. Right now I'm doing this with local files, but for some of it, I don't want the users to be able to edit the files. I currently thwart that by using "scary" file names and obfuscated data, but I want better security, but also don't want to have to jump to my cloud service just to pull their settings, because I want functionality when internet connectivity doesn't exist.
How do I do this? I feel like this is something that should be pretty commonly used feature in apps.
I never worked on Windows 8/8.1 apps, so maybe there is some integrated feature to do what yout want, but I didn't find anything on that subject.
In fact, what I found seems to indicate the opposite :
If you want the data of your Windows Store app to be secured, you have
to do it by yourself.
Depending on the desired level of security you could try using some form of encryption for your local files.
This would make the settings unreadable by the user, and prevent them to tamper with it.
But as pointed in Windows 8 Apps - Local Storage Security, encryption might not be the best way if you really want to make sure the data cannot be edited outside your app, since it is possible to extract the key from your app and decode the data.

Minimize Windows 8 Store App while tracking location with GPS

I'm working on a metro app and am having trouble finding how not to show the application.
We recently deployed tablets to our field reps, and need to add gps tracking. GPS is much easier to deal with in the metro libs (it's like 4 lines of code vs. unmanaged) so we're hoping to be able to push a metro app instead of spending time coding a winforms/wpf desktop app (the tablets are full version windows, so it's an option if we can't hide a metro app. I feel like it should be possible though as the start screen tiles update automatically without opening the main program).
In WPF, it's fairly simple to make a window invisible. I'm creating the metro app in wpf, but it uses different libs than desktop and I may just not know how to do it.
In desktop programs, it's fairly simple. You do something along the lines of:
<Page
x:Class = xxxxxxxx
..
Visibility="Hidden">
Unfortunately, with metro, the only options I have are collapsed and visible. Collapsed doesn't seem to have any effect, unless it's just because it's not deployed and visual studio shows it anyway...
So basically I'm trying to figure out if there's a way to start the program minimized or hidden so that it doesn't interrupt the field reps every time it takes their location.
If you really want to make a metro app and want it to run "minimised" you will need to look at background task. To start the background task the user would still need to start the app at least once, futhermore background task have limitation how how often and how long they can run. Also there is a lot of constraint on deploying a windows store app if you cannot publish it in the store.
If your goal is to just have access to GPS through C# apis, the GPS is actually one of the winRT api you can use from the desktop, you can find a tutorial on how to access winRT api from the desktop here
Here is the complete list of winRT api accessible from the desktop (You can find Geoposition class among them).
Have you looked into creating a background task that transmits GPS? The background task can run without the app running.
I am not entirely certain you can voluntarily minimize a Windows Store App on a user's behalf. I see nothing in IntelliSense about it, nor have I found anything online or see any app do it.
However, be aware that deploying the app without using the Windows Store -- sideloading -- requires Windows 8 Enterprise edition computers joined to the domain OR Windows 8 Pro with a sideloading key ($30 per key, purchased in packs of at least 100.) Perhaps a WPF app with unmanaged code is worth the money and effort.

Categories

Resources