如何将 Android 应用程序连接到 MySQL 数据库? [英] How to connect Android app to MySQL database?

查看:57
本文介绍了如何将 Android 应用程序连接到 MySQL 数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个使用 mysql 数据库的网站.我想知道如何将我的应用连接到该数据库.

I have a website already setup which uses mysql database. I want to know how can i connect my app to that database.

我想要实现的是我的应用程序应该请求查找已定义ID"或名称的表.该表包含指向图像或图像名称的链接.我希望应用程序检索这些图像并将它们显示在 android 应用程序上.

What i wanna achieve is that my app should make a request to find a table of a defined "ID" or name. The table contains links to images or image names. I want the app to retrieve those images and display them on the android app.

有哪些方法可以做到这一点?我可以用 PHP 开发安卓应用吗?

What are the ways this can be done? Can I use PHP to develop an android app?

推荐答案

Android 不支持开箱即用的 MySQL.访问数据库的正常"方式是在它前面放置一个 Restful 服务器,并使用 HTTPS 协议连接到 Restful 前端.

Android does not support MySQL out of the box. The "normal" way to access your database would be to put a Restful server in front of it and use the HTTPS protocol to connect to the Restful front end.

查看ContentProvider.它通常用于访问本地数据库 (SQLite),但也可用于从任何数据存储中获取数据.

Have a look at ContentProvider. It is normally used to access a local database (SQLite) but it can be used to get data from any data store.

我确实建议您在本地查看所有/部分网站数据的本地副本,这样当 Android 设备没有连接时,您的应用程序仍然可以运行.如果您沿着这条路线走下去,那么可以使用一项服务来保持两个数据库的同步.

I do recommend that you look at having a local copy of all/some of your websites data locally, that way your app will still work when the Android device hasn't got a connection. If you go down this route then a service can be used to keep the two databases in sync.

这篇关于如何将 Android 应用程序连接到 MySQL 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆