当前位置: 动力学知识库 > 问答 > 编程问答 >

heroku android beginning

问题描述:

Hi I am currently making a simple application in android that would connect to my database in Heroku and I was just wondering how I would use java code to connect to that database and fetch, and data to and from it?

Could someone give me advice on how to start. I was looking at this code for starters https://github.com/heroku/devcenter-java-database but I am still confused on how to fully understand the code. Do I need a .pom file and what is it for? And where are the values of "DATABASE_URL" and how would I be able to connect to my database that I made in Heroku etc.

Thank you for the help

网友答案:

Generally you wouldn't have a mobile phone connect directly to your database. You'd need to allow access to your db from the internet, its considered a bad idea for security. Instead you write a webservice that sits between your db and your client. The webservice reads the database, packages it up into some data format like XML or JSON, and sends it to the client who parses those values and does something with them (display, calculations, etc).

网友答案:

@Gabe Sechan is right. you need to build a API. your app will query the API and the API will get the data from db and sent back to Android via JSON...

To learn more abour API have a look here : http://www.andrewhavens.com/posts/20/beginners-guide-to-creating-a-rest-api/

or a list of tutorials

http://blog.mashape.com/list-of-40-tutorials-on-how-to-create-an-api/

Hope this helps u buddy.

分享给朋友:
您可能感兴趣的文章:
随机阅读: