× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Android: Content provider best practices

Xaver Kapeller
Mar 13, 2015
<p>I think if possible you should always use a <code>ContentProvider</code>. In previous Android versions it was more customary to use a DbHelper or DbManager to do CRUD operations but that has changed. <code>ContentProvider</code> already bring a lot of functionality with them that you wold otherwise have to write yourself and they do a lot of work for you e.g. thread safety etc.</p> <p>As for your other question: Usually you only have one <code>ContentProvider</code> per app. Or it should at least be avoided to have more than one if it is possible and it fits into your requirements. One case where I would say more than one is justified would be if you have data which should not be accessible to other apps and other data which should be accessible to other apps.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/22597099/Android:%20Content%20provider%20best%20practices/22597488">Stack Overflow</a>.</p>
comments powered by Disqus