Re: [android-developers] To ContentProvide Sqlite DB or Not

2012-10-22 Thread ncdroid
Thanks a lot for your feedback Mark.  Do you have a rule of thumb you apply 
to decide on AsyncTasks vs Loaders?  For example, if you expect something 
to take less than x mins, use AsyncTask, otherwise use a Loader?

On Sunday, October 21, 2012 5:36:10 PM UTC-4, Mark Murphy (a Commons Guy) 
wrote:

 On Fri, Oct 19, 2012 at 8:13 PM, ncdroid jbl...@gmail.com javascript: 
 wrote: 
  Can someone please answer definitively for me the following: 
  
  Are ContentProviders required to use Loaders w/Sqlite? 

 No. If you really want to use loaders with SQLite directly, I have a 
 SQLiteCursorLoader that works without a ContentProvider: 

 https://github.com/commonsguy/cwac-loaderex 

  If ContentProviders are *not* required to use Loaders w/Sqlite, is there 
 any 
  recommended example which shows how to use the two together? 

 What is (are?) the two in this sentence? 

  If Sqlite has a recommended way to achieve functional parity to Loaders 
 with 
  another method, what is that method? 

 :: shrug :: 

 I use ordinary AsyncTasks myself, way more often than Loaders. 

 -- 
 Mark Murphy (a Commons Guy) 
 http://commonsware.com | http://github.com/commonsguy 
 http://commonsware.com/blog | http://twitter.com/commonsguy 

 _The Busy Coder's Guide to Android Development_ Version 4.2 Available! 


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] To ContentProvide Sqlite DB or Not

2012-10-22 Thread ncdroid
Thanks again for sharing your experience and guidance on this subject 
Mark.  After getting lost in the documentation for so many hours, nice to 
have this communicated in such matter of fact language.

On Monday, October 22, 2012 4:54:10 PM UTC-4, Mark Murphy (a Commons Guy) 
wrote:

 On Mon, Oct 22, 2012 at 4:25 PM, ncdroid jbl...@gmail.com javascript: 
 wrote: 
  Thanks a lot for your feedback Mark.  Do you have a rule of thumb you 
 apply 
  to decide on AsyncTasks vs Loaders?  For example, if you expect 
 something to 
  take less than x mins, use AsyncTask, otherwise use a Loader? 

 CursorLoader and my loaders *use* AsyncTask under the covers. Hence, 
 time (take less than x mins) is not a particularly useful metric 
 here -- the behavior using Loaders or using AsyncTask directly should 
 be roughly equivalent. 

 If you like the Loader framework, use it, particularly if you are also 
 using a ContentProvider. 

 If you do not like the Loader framework, don't use it. Unlike, say, 
 trying to avoid EditText, the use of Loaders is purely optional. In 
 particular: 

 -- you can't use Loaders on API Level 10 and below unless you are also 
 inheriting from FragmentActivity 

 -- you can only use Loaders from an Activity, not a Service, at least at 
 present 

 In those cases, your hands are tied: you have to avoid Loaders. 

 -- 
 Mark Murphy (a Commons Guy) 
 http://commonsware.com | http://github.com/commonsguy 
 http://commonsware.com/blog | http://twitter.com/commonsguy 

 _The Busy Coder's Guide to Android Development_ Version 4.2 Available! 


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] To ContentProvide Sqlite DB or Not

2012-10-21 Thread ncdroid
Group:

I am very confused about the need to wrap a ContentProvider around a sqlite 
db if the db is to only be used locally.  I have no plans to expose the 
data in my sqlite db to any other app.

The quote on the following page would indicate a cp is not necessary if the 
data is only to be accessed by the local application:

*You don't need a provider to use an SQLite database if the use is 
entirely within your own application.*
http://developer.android.com/guide/topics/providers/content-provider-creating.html

That said, it seems every other piece of documentation on the web espouses 
the use of ContentProviders since they aid multi-threaded programming via 
the use of Loaders.

Can someone please answer definitively for me the following:


   1. Are ContentProviders required to use Loaders w/Sqlite?
   2. If ContentProviders are *not* required to use Loaders w/Sqlite, is 
   there any recommended example which shows how to use the two together?
  1. I really like the update notification feature of Loaders so this 
  would aid me greatly
   3. If Sqlite has a recommended way to achieve functional parity to 
   Loaders with another method, what is that method?

Hopefully this all makes sense.  I have been reading all day, and that 
quote in the Google docs worries me.  I don't want to waste time creating 
the ContentProvider layer if it is a waste of time.  I don't have any idea 
why the google doc says ContentProviders are not necessary with a local 
Sqlite data store--when it seems absolutely required to have a 
ContentProvider in order to be able to use the cool functionality of 
Loaders?

Thanks in advance.

-ncdroid

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en