技术控

    今日:117| 主题:49431
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Using a simple SQLite database in your Android app

[复制链接]
素颜马尾好菇凉 发表于 2016-10-6 14:23:28
211 7

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

Using a simple SQLite database in your Android app-1 (Android,management,different,published,available)

   I recently published a tutorial describing the different available methods to store data locally in an Android app . However, due to article length constraints, I could not adequately cover creating and using an SQLite database for data persistence. In this tutorial, I delve into how to use an SQLite database in more detail.
  What is SQLite.

   SQLite is a relational database management system, similar to Oracle, MySQL, PostgreSQL and SQL Server. It implements most of the SQL standard, but unlike the four database engines mentioned above, it is not a client-server database engine. Rather, it is embedded into the end program. What this means is that you can bundle a SQLite database with your application, and get access to all the power of a relational database within your application. SQLite is native to both Android and iOS, and every app can create and use an SQLite database if they so desire. In fact, in Android, device contacts, and media are stored and referenced using SQLite databases. An exciting tidbit of information is that SQLite is the most used database engine in the world, and quite possibly the most widely deployed software ever . To read more about SQLite databases, visit the SQLite web site .
  Preparation

   Regular readers of this series will notice that we’ve recently begun using the Android data binding techniques for tutorials. If you are not familiar with the concept, check out my previous article discussingAndroid data binding. Also, we use recyclerview to display lists, as alsodiscussed previously. You may want to read both if you aren’t familiar with the concepts.
  To enable data binding in your app, you must add the following to your app build.gradle file
  [code]dataBinding.enabled = true[/code]  Also, to use both recyclerview and cardview to display lists, you must include the relevant libraries to the dependencies section in your app build.gradle file (24.2.1 was the current library version at the time of writing).
  [code]dependencies {
        ...
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
}[/code]  Finally, some SQL experience will be very helpful, although you will still be able to follow the tutorial without previous experience with SQL. However, to unlock the full possibilities of using an SQLite database, you must study SQL syntax.

Using a simple SQLite database in your Android app-2 (Android,management,different,published,available)
   See also: Data Binding in Android     3     Sample app description

  For the sample app, we are going to create two tables, an Employer table and an Employee table. The Employee table will contain a foreign key reference to the Employer table, and we will show how to insert, select, update and delete rows from tables. We will also demonstrate how easy it can be to display items selected from an SQLite database in a RecyclerView (list) and in a Spinner.
  We’ve got a MainActivity, from which we can navigate to either the EmployerActivity (for operating on the Employer table), or the EmployeeActivity (for operating on the Employee table).
12345下一页
友荐云推荐




上一篇:Spring Data Series: Spring Data in a Nutshell
下一篇:换7记:小博PHP7上试跑
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

cjkfa 发表于 2016-10-6 16:54:15
这是一个KB的故事,当你在半夜12点的时候穿着黑色的衣服对着镜子用梳子梳下就会看到…头皮…屑!
回复 支持 反对

使用道具 举报

﹌花祭ゞ 发表于 2016-10-22 02:48:19
我是﹌花祭ゞ,我是新手~~
回复 支持 反对

使用道具 举报

kena69 发表于 2016-10-26 10:41:30
路过。。。。
回复 支持 反对

使用道具 举报

vmqve 发表于 2016-11-9 22:03:51
元芳你怎么看?
回复 支持 反对

使用道具 举报

杜丽 发表于 2016-11-16 22:33:49
绘一场生死契阔的游戏,为我们的故事写一个结局。
回复 支持 反对

使用道具 举报

离开我伱才会幸福 发表于 2016-11-18 14:22:53
我回帖楼主给加积分吗?
回复 支持 反对

使用道具 举报

glue_ak47 发表于 2016-11-19 22:31:34
永远不要给背叛过自己的朋友第二次背叛的机会。
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表