I'm practicing some IOS coding in Swift 2 which consists in an app fetching information from a MySQL database.
However, I'm confused in the concept. So currently my idea of how to accomplish this is that somehow the IOS App connects to the Apache Tomcat. To be able to do this, I though about creating a Java application that connects to the MySql using JNDI. With this I fetch the data and store it in a JSON object.
However this is where I get stuck. Should I return this object to the IOS application or store it in a text file or JSON file and have the IOS application read it from there?
If I had to return the object, how can I do this? I've looked around but most examples are fetching information from an API and currently I want to do it locally.
The easiest way is to create a PHP file to connect and retrieve data from MySQL, and then you call this file by swift.
You will find a useful information in the following link :
How to make an HTTP request in Swift?
Related
Currently I stored data from my Android / Java app in SQLite on the device. I want to dump this delimited/structured data to a mysql insance on Google CloudSQL. I have a google cloud account, setup a DB and have the cloud back end all ready. I have plenty of DB experience but am weak on java, cloud, etc After months of seeking working examples (GAE?) I know about this link:
https://cloud.google.com/appengine/docs/java/cloud-sql/
But it's not complete.
Can someone just post a very simple app that successfully executes a simple insert from Android/Java into Google CloudSQL and include all the code needed to get the data to the CloudSQL instance?
If this is a duplicate question and the complete code sample is already on StackOverflow I will gladly read it. I have not found a complete example yet.
Thanks in advance.
Try using Firebase or Realm instead to facilitate data flow to your mobile App. Firebase is built on reactive programming model where data is saved in Friebase and automatically synced with client device. Realm goes a step ahead in having you abstract a true API call via its interface. And otherwise yes as others responded your mobile app HAS to actually call an API service and not CloudSQL directly
Hi I want to send data from my android app to server and store in the Mysql database. But I want to use REST method to send the data and I want to create a Java app on the server side that will show the data in table format .
I have created the android app but don't know how to upload data using REST. The data which I want to send is latitude and longitude of current location.
And after refreshing the java page new data will be viewed on the page.
Please tell me how to do this task.
Thanks in advance.
You can use some framework to communicate with a server. I think retrofit is the best choice for REST API: http://square.github.io/retrofit/
But you can try the Volley. Or the HttpUrlConnection and DefaultHttpClient in android sdk.
This is a big question that would need more space than here to cover. To get started you could try looking at the spring boot or drop wizard frameworks for creating your REST service.
Coursera also has a course programming web services that might help you get started.
Alternatively, there are services like Parse that look after the backend process for you.
I am looking for some tutorials and guidelines on how to save information entered into a form containing text fields to a data base on the server.
On a second level, I would like to be able to send notifications to the application on the phone based on information stored in the data base.
Thanks...
It is advisable to store data locally in sqlite in the device and send it to the server probably through a webservice, or directly connect to SQL Server using asynctask. Google more about these.
Notifications, again webservices or c2dm will help
i had used eclipse to develop an android apps that can allow user to register.
after they register successfully and go into the main page, they are able to see their own profile which consists of the details they keyed in during register. (The details will saved into phpmyadmin)
any method can retrieve those details from the database and display it on the profile page? (i am using php and java)
thanks for answering..
You can always use "Zend AmF" or "AMF PHP" for comunicating with the app, binary.
http://www.silexlabs.org/amfphp/
http://framework.zend.com/manual/1.12/en/zend.amf.html
or amf mixed with codeigniter
https://github.com/EllisLab/CodeIgniter
Then use:
- http://code.google.com/p/klio-mobile-dataservice/
to connect with your server
You need to have a server, like a Tomcat, or anyother server, to which you will post the data
The Servlet or the PHP script, will read the values, store them in database.
The Android application will get the data from another Servlet or a PHP page, using a HTTP Get request, and show it on the screen.
You can alternatively, store the keys locally in the device, using SharedPreferences, and get them in the next screen.
You have to write a php script wich parses data from your database into for example JSON-Format. If you had parsed the json you can use the JSON parser in android to show he content in your activitys.
Here is a very nice tutorial for json parsing in android:
http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
Basically you have to create Web Service in PHP or Java and from there you need to get your data.
You have to create Restful API which returns data in the form of XML or JSON and you need to parse those data at android end. By this way you can get your data from PHP.
Here is the best resource which i found when i was searching for this kind of scenario. The author has explained very well in this and you will get very good idea about the scenario. Also provide sample code for reference.
Refer this link.
Hope this helps!
I'm in the process of designing an Android application right now.
I understand SQLite works on the phone device within the file structure. However I'm not sure if it's practical for our use.
If I'm wanting to store data that's available to all users (i.e. if someone updates their profile, it can be seen by all other users), can that be done using SQLite somehow? Or must we use a client-server model such as MySQL?
Is it practical to store user-specific information using SQLite and public information using MySQL?
Thank you
What you want to do is a Client-Server Architecture, store the data in your central server and get a copy of the working data on the phone. MySQL and SQLite don't share everything but it's close. Read the documentation on SQLite and you will see.
SQLite can't serve files like MySQL if that's your question via the network. You'll have to write that on your own. I suggest making a webservice.
If you want info to be available to all users you need a client-server model such as MySQL.
If you use SQL Lite, the only possible way to update that info without requesting it from a server is to make an Update on the application (not doable).
Don't forget that you'll require internet ON for these types of applications.
you mean all users going to use a single phone, probably not, the reason for recommending sqlite database for android is that its the lightweight, non memory eater and thus best suitable to mobile phones. Sqlite database can be used in phone while at server side we can use any. The only thing is use a method like sending xml request to server from phone, where server will send respond as xml or json, while the phone parse the xml and use the data in it. this is how online apps works in mobile phones..... ya ofcourse use mysql at server side and do the communication using as request - response yes the client-server.
Is it practical to store user-specific information using SQL Lite and public information using MySQL?
Yes, This is exactly what I'm doing with my app. It's a very common practice. I am storing information in a MySql db stored on a server that all users can read from. They can pull specific information to the device. From there I have a class in the app that stores information that they've selected within a SQLite db. You'll easily be able to add information to the MySql db on the server that all users can view.
yeah i think the model you are proposing should have no problem. Even i'm using a model something similar to what you are saying. I store some information on local sqlite db and majority of information in mysql db. For sending data from android device to mysql db you will have to write a mysql scipt on a page and android device will hit that page with the help of http request. You can send your data in that http request