android中如何连接数据库?
我是创建 Android 应用程序的新手。我使用 xammp 创建了一个数据库,并使用 eclipse 创建了一个简单的登录布局。现在我想连接我的登录页面和我创建的数据库,以便当用户输入他/她的用户名和密码时,它将打开应用程序的主菜单。我希望有人可以帮助我如何做到这一点。提前致谢。
I am newbie in creating android app. I have created a database using xammp and a simple login layout using eclipse. Now I want to connect my login page and the database I created so that when the user enters his/her username and password it will then open the main menu of the application. I am hoping for someone who could help me on how to do this. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个代码......它将帮助你
data = openOrCreateDatabase(
“自动配置文件.db”
, SQLiteDatabase.CREATE_IF_NECESSARY
, 无效的
);
Try this code .....it will help u
data = openOrCreateDatabase(
"AutoProfiles.db"
, SQLiteDatabase.CREATE_IF_NECESSARY
, null
);
你的问题有点令人困惑......数据库在哪里进入图片。数据库是用来存储登录信息来判断当前是哪个用户登录的吗?
如果是这种情况:
YOur question is a bit confusing... Where does the database get into the Picture. Is the database used to store login information to determine which user is currently logged in?
If this is the case:
我实际上正在使用我的应用程序开展类似的项目。这是一个简单的教程,对我的项目帮助很大。它解释了很多关于数据库如何使用 Eclipse 在 Android 中工作以及如何设置、添加、删除、更新数据库以及从该数据库获取数据的信息。
http://www.smashingmagazine.com/2011/03/28/get-started-developing-for-android-with-eclipse-reloaded/" smashingmagazine.com/2011/03/28/get-started-development-for-android-with-eclipse-reloaded/
希望它能帮助你,就像它帮助我一样
I am actually working on a similar project with my application. Here is a simple tutorial that has helped me alot with my project. It explains alot about how a database works in android using eclipse and how to set one up, add, remove, update and get data from that database then.
http://www.smashingmagazine.com/2011/03/28/get-started-developing-for-android-with-eclipse-reloaded/
Hope it helps you as much as it helped me
如果您想连接到 Mysql 数据库,您可能需要使用 Web 服务,例如 PHP。
操作方法如下:
PHP 文件可以采用GET 或 POST 参数
示例片段:
If you want to connect to a Mysql database you may need to use webservice such as PHP .
Here is how you do it :
The PHP file can either take GET or POST arguments
Example Snippet :