• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Connect my android Application to SQL database using Java

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friends,

I am a new Android Developer and I'd like to learn how to get some data from user through my android app, then send and save it to SQL database using Netbeans or eclipse.

If anyone have any useful tutorials on that topic, i will be so grateful.

Thanks,
 
Bartender
Posts: 7488
171
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NetBeans and Eclipse are IDEs - they play no role in saving data to a DB.

The usual approach would be to implement a REST API for access to your DB. That might utilize the JAX-RS API running in a servlet container such as Tomcat. The Android app might just use the java.net classes to access the API, or use an HTTP client library such as https://github.com/afollestad/bridge.
 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To connect android to MySQL, you need to involve third party - PHP
You may refer to this tutorial How to connect Android with PHP, MySQL
 
Ahmed Gamal Eldin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any alternatives to using PHP ?

I searched the internet and found that serverlet or similar can used which use Java not PHP but till know didn't get a starting point to learn.

Thanks in advance
 
Ahmed Gamal Eldin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim

My question is that : i have an android app (developed using Android Studio)  and want to build a database (using SQL for example) from the user input data to my App. Later my app should bbe also able to retrieve the data from this database when requested.

I believe that there should be an intermediate interface between my app and the SQL database. I'd like to learn about developing this interface and prefer to use Java not PHP.

Anyone can help ?
 
Tim Moores
Bartender
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's how I understood it. The technologies I mentioned can be used to implement that using Java. Did you have a look at them?
 
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahmed,

The people that have posted are sharing the right technologies to utilize.  The intermediate interface you are talking about is the RESTful API.  The flow of data input/retrieval in an Android App (and the standard for all Native Client/Server App), App (Android) <-> RESTful API <-> Database.  The RESTful API is not a small part of any scale application.  I live to follow a Model, View, Controller concept of each of the programmable (App & RESTful API).  This concept is obvious how it would work in the App, but not as clear in how it would work in the RESTful API as the API by nature doesn't have a view, but if you treat the RESTful API endpoint as the view, it becomes easier.

Each of your tables should relate directly to a class within your app, these are the models.  They contain a field/property for each column in the DB.  The controller is the class the gets or inserts the data from the database and does any additional work prior to responding back to the calling object.  The view is where the returned data object is packaged into either the JSON Array or XML.  
 
Ahmed Gamal Eldin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Robert for your nice clarification

Now, i will try to read about RESTful API to learn more about implementing this part.
 
Marshal
Posts: 77567
372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...and welcome to the Ranch RJ
 
Ahmed Gamal Eldin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for your co-operation and useful information.

However, i got lost while searching the internet for materials/tutorials to get starting with transferring data between my android app (Android Studio) and my database (MySQL) through serverlet and RESTful web services.

I will be so grateful if anyone with relevant experience supply me with a good website or tutorial link to start.

Thanks,
 
Tim Moores
Bartender
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Android Studio is an IDE - it's only marginally relevant to the problem at hand.

I mentioned Tomcat - do you have that running yet? If not, that would be a good start, as you'll need to be familiar with it (or a similar servlet container). The Tomcat web site has tons of information about how to get started.

And if you search for "JAX-RS example web app" or some such phrase, you'll get lots of tutorials that'll get you started.
 
Replace the word "snake" with "danger noodle" in all tiny ads.
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic