2

I need to learn how to use databases for my application, so I have decided to go with vogella's tutorial as most of his other tutorials are very helpful. I just have a few questions to make sure my application will be compatible across devices.

He mentions that his tutorial will use the Async loader class

This tutorial describes how to use the SQLite database in Android applications. It also demonstrates how to use existing ContentProvider and how to define new ones. It also demonstrates the usage of the Loader framework which allows to load data asynchronously.

http://developer.android.com/reference/android/content/AsyncTaskLoader.html shows that the minimum API level is 11?

How should I go about learning SQLite in Android? Should I use this tutorial? I want to make sure I'm using the best standards, yet getting compatibility as far back as possible (At least API level 7)

asked Aug 17, 2012 at 22:10

2 Answers 2

2

It's generally best practice to make SQLite calls asynchronously. You could use the Android support library which has AsyncTaskLoader, but I usually just extend AsyncTask, which was introduced in API level 3.

answered Aug 17, 2012 at 22:27
Sign up to request clarification or add additional context in comments.

5 Comments

Would you follow the tutorial listed above? Or would you follow something else?
@EGHDK yes, good & up-to-date tutorial without flaws. Certainly (one of) the best out there.
It looks very comprehensive, and like zapl said, up-to-date. If you're looking for a simple introduction to SQLite on Android, it might be more than you need, but it covers good practices. It would be worth going through eventually.
I guess I'll go through it now, and learn the "hard way". I just want to make sure I'm using the best practices available. Also, @TylerTreat why do you use AsyncTask instead if it's "recommended" to use Async Task Loader?
Well, there is a little more to it than what I said. AsyncTask is very quick and easy to implement, but it can potentially cause memory-leak issues if you have changing screen orientations mid-execution. AsyncTaskLoader is better to use if this is a concern for your application, but Loader is a newer API so again, you either need to use the support jar or simply use a higher API level. Using CursorLoader is probably the most "right" way to do it.
0

The AsyncTaskLoader is supported using the Android support library

http://developer.android.com/tools/extras/support-library.html

back to V4. CursorLoader (subclass of AsyncTaskLoader) is the preferred way for handling SQLite transactions while maintaining smooth UI flow on Android. Note that CursorLoader does require the use of a ContentProvider, so it's worth looking at ContentProviders as well.

answered Aug 17, 2012 at 22:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.