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 8642195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:42:59+00:00 2026-06-12T11:42:59+00:00

I want to use Content Provider and Content Observer from the Api level-8. I

  • 0

I want to use Content Provider and Content Observer from the Api level-8. I am able to create this in Api-15 (ICS). but i have to support my app from Api-8.

If i mention android:minSdkVersion=”8″ like this i am getting this errors
Class requires API level 11 (current min is 8): android.content.Loader.

import android.app.ListActivity;
import android.content.ContentValues;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText;

public class TodosOverviewActivity extends ListActivity implements     LoaderManager.LoaderCallbacks<Cursor> {

private static final int DELETE_ID = Menu.FIRST + 1;     
private ConverstationsAdapter adapter;
private EditText Enter_Text; 

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.todo_list);
    this.getListView().setDividerHeight(2);
    fillData();
    registerForContextMenu(getListView());
    Enter_Text = (EditText) findViewById(R.id.msg);

    findViewById(R.id.send_button).setOnClickListener(new OnClickListener() {           
        @Override
        public void onClick(View v) {   
            SendInfo();
        }
    });
}

private void SendInfo() {

    String msg = Enter_Text.getText().toString().trim();
    ContentValues values = new ContentValues();
    values.put(TodoTable.COLUMN_RECEIVER, "Reddy");
    values.put(TodoTable.COLUMN_SENDER, "RA");
    values.put(TodoTable.COLUMN_MSG, msg);

    getContentResolver().insert(MyTodoContentProvider.CONTENT_URI, values);
}

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case DELETE_ID:
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        Uri uri = Uri.parse(MyTodoContentProvider.CONTENT_URI + "/" + info.id);
        getContentResolver().delete(uri, null, null);
        fillData();
        return true;
    }
    return super.onContextItemSelected(item);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
}

private void fillData() {  
    getLoaderManager().initLoader(0, null, this);   // error here   
    adapter = new ConverstationsAdapter(TodosOverviewActivity.this, null );
    setListAdapter(adapter);
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, DELETE_ID, 0, R.string.menu_delete);
}

// Creates a new loader after the initLoader () call
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projection = { TodoTable.COLUMN_ID, TodoTable.COLUMN_MSG };
    CursorLoader cursorLoader = new CursorLoader(this,
            MyTodoContentProvider.CONTENT_URI, projection, null, null, null);
    return cursorLoader;
}

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    adapter.swapCursor(data);
}

@Override
public void onLoaderReset(Loader<Cursor> loader) {
    // data is not available anymore, delete reference
    adapter.swapCursor(null);
}
}
  • 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-12T11:43:01+00:00Added an answer on June 12, 2026 at 11:43 am

    Consider using android.support.v4.content.Loader

    Edit

    import android.support.v4.app.FragmentActivity;
    import android.support.v4.app.LoaderManager;
    import android.support.v4.content.CursorLoader;
    import android.support.v4.content.Loader;
    
    ...
    
    public class YourClass implements LoaderManager.LoaderCallbacks<Cursor> ...
    ...
    
    @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        String[] projection = { TodoTable.COLUMN_ID, TodoTable.COLUMN_MSG };
        CursorLoader cursorLoader = new CursorLoader(this,
            MyTodoContentProvider.CONTENT_URI, projection, null, null, null);
        return cursorLoader;
    }
    

    pay attention to LoaderManager.LoaderCallbacks<Cursor>

    Edit
    In any way read this CursorLoader tutorial, as for me – I prefer restartLoader() not initLoader() as in tutorial.

    Edit

    Rewrite your Activity with help of fragments(wired version):

    package de.vogella.android.todos;

    import android.database.Cursor;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.support.v4.app.FragmentManager;
    import android.support.v4.app.FragmentTransaction;
    import android.support.v4.app.ListFragment;
    import android.support.v4.app.LoaderManager;
    import android.support.v4.content.CursorLoader;
    import android.support.v4.content.Loader;
    import android.widget.EditText;
    
    public class TodosOverviewActivity extends FragmentActivity {
    
    public static class TodosOverviewListFragment extends ListFragment
            implements LoaderManager.LoaderCallbacks<Cursor> {
        private ConverstationsAdapter adapter;
        private EditText Enter_Text;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            getLoaderManager().initLoader(0, null, this);
            adapter = new ConverstationsAdapter(getActivity(), null);
            setListAdapter(adapter);
        }
    
        public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
            String[] projection = { TodoTable.COLUMN_ID, TodoTable.COLUMN_MSG };
            CursorLoader cursorLoader = new CursorLoader(getActivity(),
                    MyTodoContentProvider.CONTENT_URI, projection, null, null,
                    null);
            return cursorLoader;
        }
    
        public void onLoadFinished(Loader<Cursor> arg0, Cursor data) {
            adapter.swapCursor(data);
        }
    
        public void onLoaderReset(Loader<Cursor> arg0) {
            adapter.swapCursor(null);
        }
    }
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager
                .beginTransaction();
        TodosOverviewListFragment fragment = new TodosOverviewListFragment();
        fragmentTransaction.add(fragment, "xx");
        fragmentTransaction.commit();
    }
    }
    

    manifest:
    uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"

    add Support package to your project (project->Android Tools)

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

Sidebar

Related Questions

So basically, I have this content provider which I use to store and retrieve
I want to create a picture chooser from gallery. I use code intent =
I want to use SOLR's remote-streaming facility to extract and index the content of
For testing purposes I want to use Jetty 8 to serve only static content.
I've used mime_content_type() and File info but i never successed. i want to use
I want to make editable cells with multi-lines content in QTreeWidget and I use
I want use this 1 for using Bar code or QR code scanner. I
I want use BYTE_ORDER macro in my Xcode project but i can't because i
I manage to create a working CursorWrapper , but get stuck when I want
I want to store some data in the content provider, so some of my

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.