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

  • Home
  • SEARCH
  • 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 9157339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:59:26+00:00 2026-06-17T12:59:26+00:00

I have an activity that goes and pulls all the users calendar events from

  • 0

I have an activity that goes and pulls all the users calendar events from the google calendar, the get inserted into the database fine but the Loader for theListFragment` of the activity never gets the callbacks to refresh the list when there is a change. I have to back out of the activity then come back in for the loader to load everything up correctly.

I have done loaders before and never had this problem, I basically copied the loader from another of my projects that works correctly so I dont under stand why its not getting the callbacks when the content changes?

this is my insert method into the database

@Override
public Uri insert(Uri uri, ContentValues values) {
    long rowID = db.insert(EVENTS_TABLE,null, values);
    Uri _uri = null;
    if(rowID > 0){
        _uri = ContentUris.withAppendedId(CONTENT_ID_URI_BASE,rowID);
        getContext().getContentResolver().notifyChange(_uri,null);

    }else{
        throw new SQLException("Failed to insert row into " + uri);
    }
    return _uri;
}

as you can see I am calling notifyChange so the adapter updates but it does not.

this is my ListFragment

@Override
public void onActivityCreated(Bundle state){
    super.onActivityCreated(state);

    lv = getListView();
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    View v = getView();
    v.setClickable(true);
    setEmptyText("No Events");
    populate();
}

public void populate(){
    mAdapter = new CalendarRowAdapter(getActivity(), R.layout.calendar_view, null,
            new String[] {CalendarProvider.EVENT,CalendarProvider.LOCATION,CalendarProvider.DESCRIPTION,CalendarProvider.START},
            new int[] {R.id.calendarEntryText,R.id.locationEntryText,R.id.descEntryText,R.id.dateEntryText},0);

    setListAdapter(mAdapter);

    getLoaderManager().initLoader(0,null,this);
}

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(getActivity(),
            CalendarProvider.CONTENT_URI,new String[] {CalendarProvider.ID,CalendarProvider.EVENT,
        CalendarProvider.LOCATION,CalendarProvider.DESCRIPTION,CalendarProvider.START}
    ,null,null,CalendarProvider.START + " COLLATE LOCALIZED ASC");
}

@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
    mAdapter.swapCursor(arg1);
    if(isResumed()){
        setListShown(true);
    }else{
        setListShownNoAnimation(true);
    }
}

@Override
public void onLoaderReset(Loader<Cursor> arg0) {
    mAdapter.swapCursor(null);

} 

like I said, everything is going into the database correctly, just the loader is not getting the callbacks to refresh the list.

the calendar events are put into the database from an AsyncTask but I dont think thats the problem

The logcat shows no errors either

EDIT

my query method

@Override
public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();
    sqlBuilder.setTables(EVENTS_TABLE);

    if(uriMatcher.match(uri) == 1){
        sqlBuilder.setProjectionMap(mMap);
    }else if(uriMatcher.match(uri) == 2){
        sqlBuilder.setProjectionMap(mMap);
        sqlBuilder.appendWhere(ID + "=?");
        selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,new String[] {uri.getLastPathSegment()});
    }
    if(sortOrder == null || sortOrder == "")
        sortOrder = START + " COLLATE LOCALIZED ASC";
    Cursor c = sqlBuilder.query(db, projection, selection, selectionArgs,null,null, sortOrder);
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
  • 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-17T12:59:28+00:00Added an answer on June 17, 2026 at 12:59 pm

    in your insert method you call notifyChange with the URI for that specific row that was inserted,but on the query side, the URI is a different URI that represents the entire data set. notifyChange on /foo/bar/1 won’t notify listeners listening for /foo/bar. So in your insert() method you need to call notifyChange with the URI for the dataset, rather than the particular row.

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

Sidebar

Related Questions

I have a main activity that takes elements from a database and displays them
I have an activity that when users press share on a file it would
I have an Activity that should only get created once. That is, onCreate can
I have an activity that I'd like to load from a preference screen. I'm
I have an activity that shows up when the phone screen goes to sleep/turns
So I have an activity that goes over my lockscreen. But when I exit
I have an app that goes between many different activities. One activity, my main
I have an activity that uses a CountDownTimer that counts down from 10. How
I have an application that goes as follows (Home being the launch activity): D
I have five activity in my app, Act1->Act2->Act3->Act4->Act5, All activity goes in single direction

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.