I apologise for the very general question but I'm looking for some advice. I have two products that I have created for a project. An android app and a website service. I want the android app to be able to connect to a PostgreSQL database in order to authenticate user login and submit a small amount of data.
The data on the PostgreSQL database will then be produced on the website. Simples!
I'm wondering if there are some tutorials or discussions that provide a simple solution to this. I've looked at loads of forums which mention using a lot of complicated protocols, frameworks, etc.
I'm just looking for some nice efficient android examples on how to achieve this.
Any advice would be appreciated.
You should not worry about android and PostgreSQL communication because they won't communicate directly.
All what you need is a simple HTTP communication between your android and the web service to send and receive information (e.g. credential for authentication)
Your web service should take care of storing and retrieving data from the database
Related
So I am planning on creating a side project which is similar to Twitter, where the basic functions are to create accounts and store data such as username/password. And for users to create statuses and allow them to be visible on a 'news feed' so it should store the status in the database as well.
The front-end will be developed and designed for Android using Java, but how will I connect it to the database and what should I be using?
I recommend you to use firebase as a back-end database. It is very easy to learn and configure. For more info visit this link: Firebase
I have been looking for an answer since an long time now and i gte answer that i Should use RestApi or i should try it with this and that code but now i want to aks what is the easiest and securest way to send data from and desktop app to an web app and then get the web apps respond and giving it back to the desktop app. I used the direct way with hardcoding the passwords and all the database things so the desktop app will directly connect to the Database but that isn't secure at all. If you could provide me with a link or with the code i would help me more then just giving hints and playing hide and seek with me :)
Thanks in advance
You could use Web Services like , RESTful or WSDL. I think you could start it from WSDL. Othewise you could use encryption methods your own.
Please refer following links to get some idea
Web Service Introduction
https://docs.oracle.com/cd/E19509-01/821-0236/ghyto/index.html
I have a website that I'm wanting to create a Java application for, and while I don't have any experience creating android applications I have a decent amount of Java experience and feel like I should be able to complete this task over some time. I'll be making use of the Java.IO package for client-side networking (On the application) and hosting a server using Java. This server application will have access to all of the same databases as the website through JDBC. (I'll be hosting it all on the same server.)
My question is how to go about handling connections on the android platform, currently I verify a dynamically generated salt with the database salt on every page refresh to prevent session theft. I also make sure that the encrypted password and the user-name stored in the session match.
I could theoretically just create a standard server application, using NIO and avoding the whole thread-per-client scenario. The problem is that my website has quite a bit of traffic, and I know the application will too. So I'm running into issues on how to handle it.
If I use a keep-alive TCP connection and store the users basic information in a class data structure (Psuedo example):
class User {
int id;
}
Considering all information will be polled from a database and everything is relative to the id of an account, there's no reason to store any excess data into the User class, correct? Just a quick simple lookup tied to the connection to only get data relavent to yourself.
Should I avoid the use of TCP networking for this? What do you guys think.
On the server side, create REST web services that invoke CRUD operations on the server database, and return the responses to the client as a JSONObject or JSONArray. Android has internal support for JSON parsing, and you can use the Volley library to call the web services. Volley is a pretty abstract, high-level HTTP library that makes it very easy to make REST web service calls. TCP connections are quite low-level and are not generally used in client-server Android apps. See the Transmitting Network Data tutorial for more on this.
Currently i have a website offering some product. The webserver sits on the same system as the database and directly accesses it to retrieve the required information for the HTML frontend. Now i think it is good to separate the database from the webserver via an API server. The reason why i want to use an API server is that it might be possible that future applications, other than the website, will need access to the information on the system.
The system which i want should consist of the following components:
A database which will store all the required information.
An API server which will be implemented in Java and should use oauth2 for authorizing user requests. The API server will have the only direct connection to the database.
A webserver.
So basically what i have in mind is that i want to build my website on top of that API server. The user will register/login/... over the website and the website implementation will internally query the API server as a webservice on behalf of the user. The API server would then return the data from the database. That way the HTML frontend is just an application using the API server and will never itself be in direct contact with the database.
I think that this is an often encountered problem for which a good solution exists. I am unsure if this solution is the way to go though. Could you help me out and/or point me in the right direction from here?
Thank you.
As far as I know, it is not advisable to have a separate API server for a couple of reasons: decreasing performance and increasing compexity of a system. So basically you should avoid this type of solution for as long as possible.
You should definitely read M. Fowler: "Enterprise Architecture Patterns" for inspiration.
Returning to your question: have you considered making this API layer as a module (library)?
If I haven't convinced you, try reading Java RMI documentation (http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136424.html)
I'am new to Android app development. I want to create a mobile application that has two entry fields.
i.e:
FirstName and
LastName
and will input into MySQL database.
Is there a basic source code example available to achieve something like this? how would i create something like this?
Thanks for your help guys.
Android access to remote SQL database will explain to you why you dont want to connect a android device directly to a SQL server of any kind. It is a bad idea.
Go do some research on how to create either a SOAP or REST service and how to consume them in Android. Here is a article on REST and here is a article on SOAP.
Once you can create web services either SOAP or REST then any device can use your service not just android.
There is some great way to generate web services for this example by using Netbeans and Eclipse. Here is a great Netbeans tutorial to get you started.