Phonegap Stand alone (Offline) Application - c#

I currently develop one web based software (Like library) (In PHP with MySQL) and now I Plan to develop that for smart phone and desktop. So I came to phonegap for smart phone. but now how can I grab data from my MySQL database to app? is it possible with JSON ? How ?
Other Question is that how can I use that app which develop in Phonegap while device is not connected to internet? My Same problem is with windows based software which I'm going to develop in C#.
Thanks...
Any type of help will appreciated.

to grab data from your MySQL database, you will need to create some PHP controller on your server to which you will send POST/GET requests from your app to retrieve/update data.
to have the app working offline, you must store previously downloaded data within devices database or introduce some caching solution (angular provides one, for example).

You should use GET/POST method in php to return the database result have wrap the whole sql result in json_encode function
i.e
echo json_encode($result);
in your offline storage you can use websql which will store it in your device storage.
since its deprecated you should probably use indexeddb for localstorage.
yes ajax will be most commonly used like $.getJSON(); methods but my favorite is
var jsonp = document.createElement("script");
jsonp.type = "text/javascript";
jsonp.src = "http://foo.com/api/ad?foo_var=4345&callback=displayinfo";
document.getElementsByTagName("body")[0].appendChild(jsonp);
function displayinfo(data) { //do your stuff }

Related

C# WP8 Connect to MySql database

I am struggling to figure out how to connect to a MySql database in my C# Windows Phone 8 application like I can on my desktop application. The reason I am struggling is because it seems I cannot just use the same MySql.Data library that I used on my desktop application. Are there any other libraries that I can use to access my database?
PS. I really don't want to go the PHP route because I will have to have Apache running on y server two and will have to add JSON interfacing two which will not only be a hassle but possibly also waste some processing time and make my application more complex.
PPS. If not possible with MySql, can it be made to work with Microsoft SQL Server or Azure?
EDIT:
If some sort of HTTP interface is my only option, is there some easy existing API or something that I can use to allow SQL data transmission or will I have to create specific PHP(/asp.net or whatever) code for each type request that I am planning to send?

How can I determine what does my mobile application require?

I'm confused between native apps and web apps in the mobile context. I don't know if I go with native mobile development then do I need to know HTML, CSS, and JavaScript. If not then how can I make that app connect to database online for example?
If I want to build an application for chatting on mobiles. Something like WhatsApp! Will knowing a programming language (e.g. Java on Android and C# on Windows Phone) will be enough to build something like that? or what other components are necessary to add?
Native apps tend to be more recommended for android apps as they are faster as it is running what it was intended i.e. java code, html web apps tend to be slower.
For what you want to do, a chat app, then a native android app, (using java code) will probably work best then trying to do it as a web app.
You would need to learn about Http connections for your chat application. If you are accessing a database, such as MySQL, then you would need to have PHP code running on a web service where the Android app can access the database.
As an example, if your application, need to query the database, then you would tell the Android app to post to the web server running the PHP code. The PHP code would run the query on the MySQL database, and the result set should be json encoded and echo'd out, that way, Android will receive the json encoded content. Then you would need to decode the json to process what was returned in some way.
Hope this helps.
For android you will need to learn Java and XML, and if you want to make a chatting application for all or either platforms you must learn SQL, (including php).

Connect to a SQL Database from Android

I want to develop an Android application which would connect to a SQL Database which is already created . We developed this news site :
e-Cmunio. This site is based on a SQL Database that already has a lot of news and stuff in. For now, what we want for our Android app is to connect to that database and show some random news in a listView.
The problem is that I don't know how to connect to it from Android.
I have already read about some WebServices, but I have no idea from where to start.
We ( me and a friend ) are in HighSchool. The site was developed in C#. We are new in Android and java, but we are familiar with algorithms and data structures.
Could you please give me some tutorials and entry-level information about how can we access our DataBase?
Sorry if I hasted your time, but I really have no idea where to start from.
The easiest way is to use PHP to parse ur data to JSon and read that data and parse it in ur Android phone..
SQL to PHP to JSon to read from.
http://www.bin-co.com/php/scripts/sql2json/
Parse JSON to Android
http://www.vogella.com/articles/AndroidJSON/
What you want to do is make a webservice on your server side that connects to your database and returns whatever you want to return in your favorite format(XML / JSON).
Next, on Android(client side) you want to have an AsyncTask to access that webservice and fetch your news and save them to your Android SQLite Database.
Later like you suggested you can load those news from a cursor directly to your listView with a Listview adapter.
You can read about Saving data in SQLite here: http://developer.android.com/training/basics/data-storage/databases.html
You can read about AsyncTask here: http://developer.android.com/reference/android/os/AsyncTask.html
You already have an elaborate answer in connect to sql server from android.
Web services define interface for your website in a standardized way, so that
other websites/applications can access it. It is more extensible and generic solution
then directly accessing server's database.
Simple web service can be just an XML or a JSON file generated after querying your
website with specific parameters. So as an exercise in your case I would implement
handling of specified URL in your C# server code and generate XML file with your
news (query in URL) and then just open your page with this URL on your android app
and read this XML. When your app will become more complex, then you can start moving to
some standard web service solution.

SqlConnection in Windows Phone

Is it possibe to save date in remote database (on server) by mobile with WP7? I wolud like to use ADO.NET and insert some values. If it is not possible what else can I use?
AFAIK you can't - I'm 100% positive you can't in WP8 or WinRT, so I assume it also holds for WP7.
The best you can do is host a web-service somewhere that will provide a RESTful access to the database, then use WebClient (or whatever way you prefer to make a HTTP request) in the phone app to call the service.
Here is a very cool tutorial :
http://studentguru.gr/b/dt008/archive/2010/12/02/querying-a-database-on-windows-phone-7-using-wcf.aspx

Grabbing MS SQL Server Data for iPhone App?

I have a pre-existing desktop application that draws its information from a Microsoft SQL Server. The desktop application is written in C#/ASP/.NET.
I'd like to take this same data and present it in an iPhone application. What would be the best way to obtain and present the data?
I would recommend writing a web service that exposes the data and then interfacing with this from the iPhone across the network.
Calling web services and making HTTP calls is very easy on the iPhone.
Do you assume your iPhone application will have network access? If so I would go the webservice route as already mentioned. If it's a small database that you want available on the iPhone with out the need to access the internet to retrieve data you could look at converting the SQL Server database into a SQLite database and packaging it with your app.

Categories