SQLite in Android part 1

本文介绍了Android应用程序中数据库的创建与管理方式,包括如何使用SQLiteOpenHelper来创建数据库及表格,并探讨了如何通过ContentProvider使数据库变为公共访问,以便于不同组件间的数据交换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Some important conclusion I drawed from tutorial.

  1. The created database will be saved in the private application folder(./data/data/YOUR_PACKAGE/database/***.db), so only the application which created the database can connect the database.
  2. If you want to make the database to be public, then you must use content provider and create the database class(sqliteOpenHelper)  as private class in content provider. Besides, the merit of using content provider lies in the easy modification of the different database systems you choosed to use.
  3. Subclass extends SQLiteOpenHelper
  4. If you want to create more than one table, you should run execSQL("Create ... ") respectively. One execSQL can only create one table, other create commando will not be concerned.
  5. It is strongly recommanded that, all the static parameter for the construction of the table in database should be put in an interface or a final class, easy to make update. Personal recommandation is to use a final class. Each table will be a private class in this final class. Private classes of tables should extends BaseColumn, so they will have the attribute _id naturally!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值