I am just a beginner in android app development and that's why I have many doubts. I am building one application where the user enters some data in editText. Now I want to save that data in my database. My database is running on my laptop. How would my app connect to the database? Do I need a web server in between? If yes then which web server is used for Android apps? Basically, i want to know the flow of data from app to the database.
Study more from Udacity.com, its free.
You may use a jdbc Connector to connect to database.
Connect your jdbc connector over local network ip\servername and database connection string
You can use REST Service when it comes to web Service on Android like this. You can either pass the values as parameters or an Object depending on your requirement. All the best
Wamp server is best option to play with server related utilities.You can use it even if you are offline. and it provides various option for data storage. It Mainly uses MySql and PHP scripts for fast performance.
For More details Click Here
Related
I am making an application similar to that of apps such as pay by phone and paymobile, which are apps used to pay for parking instead of using a parking meter and having to display a ticket in your vehicle.
I need to start with the back-end (the database) and was wondering if SQL would be appropriate for this app.
As SQLite is stored on the system (the Database) there will be data such parking details and payment details.
Will I be able to send this data to say my laptop which will act as the server for the traffic wardens device to check number plates?
Or would I have to use a sql software that is not on the applications itself?
Any thoughts and suggestions would be much appreciated :D
SQL is perfect for back end database needs. You can various flavors of SQL like Oracle or MySQL on the back end. As far as the application data being sent to the server (your backend laptop), that will be taken care by the application level programming. For android, there are various ways to send data, using the native class AsyncTask or using third party libraries like Retrofit and Volley. You need to take a decision depending on the architecture of your app.
Try this
Create database on your server
Create Web API like .Net MVC on your server
Create connection between your Web API and your database
In your mobile app you can use webservice to get our put your data to database
You can encyrpt your data on your database to more safety
do not use SQLite , because it is unsafe to keep your important data.
I have a MySQL database installed in my Amazon AWS instance (not RDS). The same database is installed in a personal computer, offline.
You have to connect to the amazon database via SSH, it is in a Ubuntu instance.
The online database contains information of 1000 users. The offline versions contain information only for that particular user.
Users use a Java desktop application to feed data into the local database. When they click on the Sync button, the 2 databases should be synced. Remember here that the desktop offline database should "upload" the newly inserted things to the online database while it should "download" new data (if any) related only to the particular user .
The system cannot be a manual way where someone manually turn on a 3rd party application, use putty or connect SSH, configure the databases etc and sync. The system should be embedded to the desktop java application.
I looked into things like SymmetricDS and it is too much complicated, not sure about the SSH access too.
Any idea about how to do this in an easy way? I am also creating a REST API thinking I can handle this manually, but if there is already built system/API I am onto it.
This is very simple and doable. Just use MySQL replication.
MySQL replication
Let me know if you want any further details. I can give you working model of my.cnf as well if required.
Br//
I am working on a project where the raspberry pi (model B) runs JAVA application to connect to and retrieve data from a Router.
What i want to know is the best approach or the best database that i should use to store that data retrieved from the router. Knowing that i will need to build another android application that should connect to that database (on the raspberry pi) and display that data.
So, what database that is compatible with the java application and the android application?
Also, later on i wish i could run the RPI as a server that enables me to connect to that database from anywhere.
Keeping in mind that:
I am new to Raspberry pi
New to Database
I suggest you to take a look at OrientDb is a NoSql Java graph-document db (you can chose) it support a lot of queries paradigm and an Sql dialect as well (you dont have the join), is fast, light, and support native rest query, i have tested it on raspberry pi (even in distributed multi-master mode on 2/3 raspberry node) and it perform well, the nice thing is that allow you to think in a different way, your data is presented like a java object an exposed you by rest paradigm in Json over http so you can think your client application on client side, using html 5 and jscript framework like angularJs for example (and you can 'deploy' your static resource direcly on the db that work like an extremly light application server)
This answer follows the previous comments. Let's say :
You have your router. Connected to it you have PC (with IP address called IP1) and your RPI with IP2.
On your RPI, I guess you have RaspBian. So with the package manager, you install mysql. You create your desired database and tables.
When using eclipse to access your database for testing purpose, or explore all data, I think you need to provide the jdbc driver, and configure the url of the db. Because you are running eclipse on your pc and you want to access the db hosted by the RPI, you should provide the IP2 address in the url.
Because your Java app will run on RPI, you can set the url to "localhost". See the following link : http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html
So, to sum up, eclipse and java app both need a mysql jdbc driver, configured the right way.
Later, you'll want to access your db through your android app. You'll need to configure your router with port forwarding, to access your db from outside. But this is out of topic. I let you search.
Almost All the Databases are Compatible with JAVA.And Hardly I belive that you will not have such privilege to choose Database while develop real time Application .
Java and Android Both are not different , both are same on a Pillar.There will be no problem because of using Database.
i suggest SQLite as Android uses it natively and it does not need that much of resources as other DBMS like *SQL
How can I connect my local database in my application? I have a database which contains a book. I have to display it in my application in J2ME
Basically, in JME, an app can create a database which is a file stored in the RMS. Actually, there are several APIs that can help you in creating a Java ME database: Is there any option for local database like Sqlite for j2me - CLDC devices?
Anyway, I think the data in a sqlite database is not easily accessible to a JME app. It is not impossible but it, maybe, is complicated. Honestly, I don't know anyway to do it.
You have to create a server application where you access to database. Also your J2ME has to communicate with your server application for getting Data you want to display (Use HttpConnection Class).
In Mobile Application, you can not directly make connection with local or remote database. To Make Connection with Database , you need a middle tier called a web service. You can create web service in any platform like Java-Servlet, .net or in PHP. See this is a very simple example to work with MySql Database.
I am making an Android application. Since it is so simple, I first thought I could simply eliminate the need for Java application on the server which acts as a middleware. I tried directly connecting to the database using the JDBC driver for MySQL but my program is crashing so I'm not sure if Android "supports" the JDBC driver for MySQL.
So I am thinking of how to implement the application. Basically the application writes some data from a remote MySQL database and retrieves some data from a remote MySQL database.
Do I connect to a Java server program using sockets (or some other method of communication)? Or could I implement a direct connection to the MySQL database from the client application?
I tried directly connecting to the
database using the JDBC driver for
MySQL but my program is crashing so
I'm not sure if Android "supports" the
JDBC driver for MySQL.
Never never never use a database driver across an Internet connection, for any database, for any platform, for any client, anywhere. That goes double for mobile. Database drivers are designed for LAN operations and are not designed for flaky/intermittent connections or high latency.
Do I connect to a Java server program
using sockets (or some other method of
communication)?
It doesn't have to be Java. It just has to be something designed for use over the Internet. As Mr. King's comment suggests, Web services have been used for this for much of the past decade. For Android, REST Web services are probably the easiest to consume, since there is no built-in support for SOAP or XML-RPC. But whether the Web service is implemented in Java, or PHP, or Perl, or SNOBOL, is up to you.
Well, OK, perhaps SNOBOL won't be a viable option. :-)
I know this might be a little late but as I ran into the same problem with a project at school I wanted to share my solution with you as you might profit out of my experiences.
Android is bad for Database-Operations so creating a normal Database-Controller wasn't a thing. Instead I created a Server in Java which handles all Database-related stuff and can also be extended (in my case I used a Feedback-function, too).
The Github-REPO is: https://github.com/Cedced-Bro/Public-Server You can check it out and this is open-source so you can use and contribute to it if you have more ideas to it.
To answer your question more properly: I would strongly suggest to NOT grant all users direct access to your DB as you can run into security issues with malicious users. This was the reason why I created this controller in the first place instead of just a PHP "forwarding"-server.