简体   繁体   English

没有ContentProvider的Android Sqlite

[英]Android Sqlite without ContentProvider

Is it possible to successfully use Sqlite on Android without also having to use a ContentProvider? 是否可以在不必使用ContentProvider的情况下在Android上成功使用Sqlite?

Can someone show me a sample that doesn't use ContentProvider? 有人可以给我看一个不使用ContentProvider的样本吗?

And if it is indeed true that Sqlite can be successfully used without it, what are examples of cases where ContentProvider would be necessary? 如果这的确是真实的sqlite的,可以成功地使用没有它,有什么情况的ContentProvider 必要的例子吗?

This site does an excellent job describing how to use SQLite in Android without managing to ever once use the term 'ContentProvider.' 站点在描述如何在Android中使用SQLite而不用一次使用“ ContentProvider”一词方面做得非常出色。

A simple Google search such as Android SQLite tutorial -"ContentProvider" will show many many more examples. 一个简单的Google搜索(例如Android SQLite tutorial -"ContentProvider"将显示更多示例。

Google is your friend. 谷歌是你的朋友。

You need to be aware that SQLite database isn't thread safe, so if you intend to have more than the one thread running at any time accessing the database, you'll definitely run into more problems than in implementing a ContentProvider . 您需要注意,SQLite数据库不是线程安全的,因此,如果您打算随时访问一个以上的线程来访问数据库,那么ContentProvider实现ContentProvider遇到更多的问题。

I strongly recommend having a ContentProvider as you can bake all the difficult SQL that cannot be mapped to ContentProvider queries into URIs instead. 我强烈建议您使用ContentProvider因为您可以将所有无法映射到ContentProvider查询的困难SQL转换为URI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM