Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:53:21+00:00 2026-06-15T02:53:21+00:00

This question would be a follow up from the one asked Content Resolver vs

  • 0

This question would be a follow up from the one asked Content Resolver vs Cursor Loader
Where the answer clearly states how to insert records into a sqlite Db using a Content Resolver . My question is the following :

  1. Can i use a loader(Normal Loader) to implement this functionality ?

eg :

    public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
            switch (id) {

    case AppConstants.LOADER_ADD_FAV_PHONE_NUM:

        ContentValues values = new ContentValues();
        values.put(DBHelper.TM_DB_COLUMN_PHONE_NUMBER,
                directionOrder);
        values.put(TransitMeDBHelper.TM_DB_COLUMN_NAME_ID, selectionArgs[0]);
        Uri insertFavStop =getContentResolver().insert(TransitMeContentProvider.CONTENT_URI_INSERT_FAV_PHONE,
                        values);
        break;
    }

return null;
}

Would this run the functionality in the Main UI thread or a worker Thread . I understand that i would not receive callbacks for this as the content resolver will return a URI instead of the cursor containing data .

I tried running this code but it behaves kind of wierd .. Duplicate inserts are recorded and its not consistient , Could someone show me to some right resource which uses a Loader to do Insert operations ( I have seen many examples with query examples and it works like a charm 🙂 )

Thank you for your time .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:53:23+00:00Added an answer on June 15, 2026 at 2:53 am

    Can i use a loader(Normal Loader) to implement this functionality ?

    You can’t use a default CursorLoader to insert data. If you implement your own Loader you could probably use the loadInBackground method to do the insert but that will make your code awkward at best(and I don’t know if it will actually work).

    Would this run the functionality in the Main UI thread or a worker
    Thread . I understand that i would not receive callbacks for this as
    the content resolver will return a URI instead of the cursor
    containing data .

    The loader callbacks will run on the thread where they are implemented(the UI main thread most likely) so you’re doing the getContentResolver().insert() on the main UI thread with the possibility of blocking the main UI thread.

    I tried running this code but it behaves kind of wierd .. Duplicate
    inserts are recorded and its not consistient ,

    Have you tested how many times is the onCreateLoader method called?

    Could someone show me to some right resource which uses a Loader to do
    Insert operations ( I have seen many examples with query examples and
    it works like a charm 🙂 )

    Don’t use/try to use a Loader to insert data in the ContentProvider/Database. It works like a charm for queries because the loaders were designed to load data from a data source(not insert data), that is their purpose. If you want to insert data use an AsyncTask(also have a look at AsyncQueryhandler), a regular thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, this question is actually a follow-up question from my previous one: What would
This is a follow up question to the one answered here: Excluding dates from
This is a follow-up to my previous question I would like to find a
This is a follow-up question to the following if you would like to see:
A simple answer to this super simple question would be great! Here is the
I asked this question (below) a week ago and got the answer I was
PHP mysql database I have created a follow on question to this one here
I guess this question that would have already been asked here. I searched but
(This is a follow-up from this previous question ). I was able to successfully
This is a follow-up to a question I asked yesterday. What I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.