我使用的是Android 2.2的API。我想知道如何连接到PostgreSQL数据库服务器。
I am using the Android 2.2 API. I want to know how to connect to a PostgreSQL database server.
我是新来这一点,所以没有任何的想法,所以请帮助我做一些样品code。
I am new to this and so have no ideas, so please help me with some sample code.
您通常不直接连接到数据库。为了达到你想要的结果,你可以做一个RESTful请求。
You usually don't connect directly to a database. To achieve the results you want, you can do a RESTful request.
这意味着,无论是发送一个JSON字符串或XML文件到服务器(你可以在PHP,Ruby程序,什么不可以)
This means, send either a JSON string or xml file to a server(which you can program in php, ruby and what not)
我不打算给你的样品code原因有字面上吨code的一个简单的谷歌搜索机器人宁静登陆实例教程
I'm not going to give you sample code cause there are literally tons of code on a simple google search "android restful login" Example tutorial
这个过程通常是:
输入登录Android设备上的凭据 - >发送POST请求到服务器 - >验证凭据数据库(在这种情况下,Postgres的) - >发送确认回导致如果登录成功)
Enter login credentials on android device -> send post request to server -> validate credentials to the database(postgres in this case) -> send verification back -> android device act upon verification(usually by loading a new activity as a result if logged in successfully)