0

I have used a code that works with SimpleCursorAdapter but in this version of Android it has been depreciated totally. So what to use instead? Because of this setListAdapter is also having errors. As i cannot lose the whole code for this one error, is there any method that can replace this? There has to be some solution.

 ListAdapter  adapter = new SimpleCursorAdapter(
                this,
                R.layout.activity_display,
                c,
                new String[] {"Usn", "Attended", "Missed"},
                new int[] {R.id.Usn,R.id.Attended,R.id.Missed});
        setListAdapter(adapter);
beginner
  • 29
  • 1
  • 9
  • Possible duplicate of [SimpleCursorAdapter deprecated in API version 15?](http://stackoverflow.com/questions/8790659/simplecursoradapter-deprecated-in-api-version-15) – Mike M. May 01 '16 at 09:11

1 Answers1

0

SimpleCursorAdapter is not deprecated. Only the constructor you are using is deprecated. Technically you can still use this constructor, but it's better to use the other constructor that has an additional argument. (You can pass 0 as the last argument if you don't need the adapter to automatically requery the cursor.)

Karakuri
  • 38,365
  • 12
  • 84
  • 104
  • thanx for the quick reply. But what other constructor? Can you please mention it? There a few constructors in the link. Which should i use? – beginner May 01 '16 at 10:14
  • @beginner The words "other constructor" in my post link directly to it. The only other constructor is the (deprecated) one you are already using. – Karakuri May 01 '16 at 21:11