Search code examples
androidactionbarsherlockadaptersimplecursoradapter

NoSuchMethodError SimpleCursorAdapter for older version of android(2.3.3)


I am developing small android application which having integration Sherlock.In my application I am using Sherlock list fragment in which I am displaying list items fetched from local database.

lv = getListView();
from = new String[] { Table.COLUMN_DESC1,COLUMN_DESC2, COLUMN_COUPONID };
to = new int[] { R.id.textView1, R.id.textView2, R.id.textView4 };
adapter = new SimpleCursorAdapter(this.getActivity(),R.layout.coupon, null, from, to, 0);
setListAdapter(adapter);
getLoaderManager().restartLoader(0, bundle, this);

Now problem is that when i ran this code on ics version of android its working fine but when i ran this on android 2.3.3 it gives following problem.

My application contains one main activity and two fragments f1, f2

when i switch from f1 to f2 its working fine without any error..

when i again switch from f2 to f1 its working fine

but when I again switch from f1 to f2 it gives following error.

01-03 01:37:04.175: E/AndroidRuntime(8010): FATAL EXCEPTION: main
01-03 01:37:04.175: E/AndroidRuntime(8010): java.lang.NoSuchMethodError:android.widget.SimpleCursorAdapter.<init>

on newer version of android works fine with this code but on older version its not working fine.... I am not able to figure out what is the problem behind it.. Need help... Thank you...


Solution

  • Try changing your Import to

    import android.support.v4.widget.SimpleCursorAdapter;