user3058783
user3058783

Reputation: 19

cursor adapter sqlite android version change

I am using tutorial of sqlite i have adapted most of the code to my requirement but facing single error of android version requirement. Basically my app requires min api 8 and following code of tutorial requires min api 11:-

can anyone help me to convert same code to suit min api 8??

dataAdapter = new SimpleCursorAdapter(
    this, R.layout.wiigsource, 
    cursor, 
    columns, 
    to,
    0);

Upvotes: 0

Views: 105

Answers (1)

Anirudha Agashe
Anirudha Agashe

Reputation: 3530

The constructor that you are using is

public SimpleCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to, int flags) 

which was added in API 11 you can use constructor

public SimpleCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to)

i.e remove the last argument 0. A detailed description about the two constructors can be found here

Edit:

But the above constructor is deprecated as rightly pointed out in the other answer. Therefore the best way would be to use

SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags)

and import the simpleCursorAdapter from

import android.support.v4.widget.SimpleCursorAdapter;

package

Upvotes: 1

Related Questions