如何在android应用程序上创建和检查用户和密码?
我有一个数据库服务器,它收集用户的用户和密码(通过从网站登录)。在android应用程序上,我想检查用户和密码,但我不知道如何发送和接收数据。
I have a database server which collect user&pass of users (by login from website). On android application, I want to check user&pass, but I don't know how I send and receive data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想查询数据库,请继续。 Java SE 和 Android 有一个名为 javax.sql 的东西,它允许您与关系数据库交互。对于要查询的特定数据库,您需要一个纯 Java JDBC 驱动程序。
您很有可能将纯 Java (SE) 驱动程序导入 android 并使其正常工作,但这并不能保证。如果驱动程序使用了 java SE 上可用的库,而不是 android 上可用的库,那么你就不走运了(但我不知道那是什么)。
话虽这么说,您最好为数据库构建一个 Web 服务前端,以允许客户端进行简化的特定查询,而不是将整个数据库暴露给客户端。这是出于安全原因,还因为通常在为移动客户端编写时最好将尽可能多的工作推到服务器上。
If you want to query your database, go ahead. Java SE and Android have something called javax.sql that allows you to interact with relational databases. You need a pure Java JDBC driver for the specific database you are querying against.
You have a good chance of being able to import the pure Java (SE) driver into android and having it work, but it's not guaranteed. if the driver uses some library that's available on java SE and not android, you are out of luck (but i don't know what that'd be).
That being said, you might be better off building a web service front end to your database to allow the client to make simplified, specific queries instead of exposing the entire database to the client. This is for security reasons, and also because in general it's better to push off as much work to the server as possible when writing for mobile clients.