【问题标题】:Inserting data to sqlite database using ContentResolver使用 ContentResolver 将数据插入到 sqlite 数据库
【发布时间】:2013-01-11 12:43:28
【问题描述】:

我想使用ContentResolver.bulk(uri, ContentValues[]) 方法。

我有sqlite 数据库存储在应用程序私有存储内的数据库文件夹下。数据库名为 mydb.db

名为 BUDGET 的表的 Uri 是什么?我需要以某种方式将ContentResolver 连接到我的数据库吗?

【问题讨论】:

  • ContentResolver.bulk 如果您使用的是 Content Provider,则使用。我认为您不能将其用于 sqlite 数据库操作。当调用批量函数时 ContentProvider 的 bulkInsert 方法被调用

标签: android android-sqlite android-contentresolver


【解决方案1】:

您需要实现一个内容提供者。然后,您的内容提供者会将数据存储在 SQLite DB 中。详情请见Android docu

【讨论】:

  • 是否值得使用常规的 sqlite 数据库?
  • 这取决于您的程序,内容提供商与CursorLoader 很好地配合使用,或者当您想要导出数据以供外部使用时。
猜你喜欢
  • 1970-01-01
  • 2018-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多