我如何将SQLite数据库连接到我的Andr​​oid应用程序吗?

问题描述:

HELP!好了,所以我一直在设计一个Android应用程序相当长的一段时间了,我一直在手动将这些数据转换为字符串,然后就拉着他们在我的布局,但后来我的一个朋友建议我把所有必需的数据成数据库,然后就拔不出来了那里的每个活动....听起来不错....接受我一直在阅读教程教程后是如何工作的,似乎不仅仅是做很多很多的字符串和实例更难在教程的每个为自己的目的,这不是我和剂量不作任何了解我更容易。所有我会需要这个数据库做的是读取和显示信息,我想它的布局。我创造了这个数据库SQLite数据库浏览器。

HELP! Okay so I have been designing an android app for quite some time now and I have been manually putting all this data into strings and then just pulling them up in my layouts, but then a friend of mine suggested I put all the necessary data into a database and then just pull it out of there on each activity....sounds good....Accept I have been reading tutorial after tutorial on how this works and it seems much harder than just making lots and lots of strings and the examples in the tutorials each serve their own purpose which is not mine and dose not make understanding any easier for me. All I will be needing this database to do is read and display the info where I want it on the layouts. I created this database with SQLite Database Browser.

数据库结构:

Database structure:

名称 - fishindex_db
表 - 鱼,州,章
行:
鱼 - _id,名称,说明,禄
状态 - _id,名称,简称,更新
章 - _id,名称,规格,季节,数量,备注

Name - fishindex_db
Tables - fish, states, reg
Rows:
fish - _id, name, desc, loc
states - _id, name, abbr, updated
reg - _id, name, size, season, quantity, notes

所以现在说我要显示来自主键(_id)布局中的列表视图中的所有内容12从寄存器表这是怎么做的?需要的.java和.xml code例子吧。

so now say I want to display all the content from primary key (_id) 12 from the reg table in a layout list view how is this done? need .java and .xml code example please.

这是两个教程,你可以用它来让你和在运行方面要达到什么样的:

These are two tutorials you can use to get you up and running in terms of what you want to achieve:

  • Android SQLite Database Tutorial
  • How to connect Android with PHP, MySQL - this one takes it a bit further in showing you how to connect to production databases and consume web services.

希望这有助于。