Cannot resolve constructor

I have an error that I don't know why in my Galaxy Ace Samsung(Android 2.3.6) doesn't work but in my Motorola G (Android 4.4) works perfectly. The exception are so strange this is my code:

adapter = new SimpleCursorAdapter(this,R.layout.single_row_profession, cursor,from,to,0);

package com.orun.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.orun.database.DataBaseManager;
import com.orun.model.Profession;
import com.orun.s.SConnection;


public class ProfessionsActivity extends Activity {

public static SConnection sConnection;
public static DataBaseManager manager;
private static Cursor cursor;
private static ListView listView;
private static SimpleCursorAdapter adapter;
private static EditText etSearch;
private static ImageButton btSearch;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_professions);
    SharedPreferences sharedPref = getSharedPreferences(getString(R.string.PREFERENCE_FILE_KEY), Context.MODE_PRIVATE);
    Toast.makeText(getApplicationContext(), "Rol "+sharedPref.getString("ROL","Estudiante"),Toast.LENGTH_LONG).show();
    manager = new DataBaseManager(this);
    listView = (ListView) findViewById(R.id.listView);
    etSearch = (EditText)findViewById(R.id.etSearch);
    new LoadTask().execute();
    cursor = manager.searchProfession(etSearch.getText().toString());
    int[] to  = new int[]{R.id.textCode, R.id.textName,R.id.textType};
    String[] from = new String[]{"_id","name","type"};
    try {
        adapter = new SimpleCursorAdapter(this,R.layout.single_row_profession, cursor,from,to,0);
    }catch (Exception e){
        e.printStackTrace();
    }
    listView.setAdapter(adapter);
    etSearch.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            new SearchTask().execute();
            adapter.changeCursor(cursor);

        }
        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {}
        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {}

    });
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(ProfessionsActivity.this,PrincipalActivity.class);
            int codeProfession = Integer.parseInt(((TextView)(view.findViewById(R.id.textCode))).getText().toString());
            SharedPreferences sharedPref = getSharedPreferences(getString(R.string.PREFERENCE_FILE_KEY), Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("CODE_PROFESSION", codeProfession);
            editor.commit();
            startActivity(intent);
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.professions, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

private class SearchTask extends AsyncTask<Void, Void, Void>{
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(Void... params) {
        cursor = manager.searchProfession(etSearch.getText().toString());
        return null;
    }


    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
    }
}

private class LoadTask extends AsyncTask<Void, Void, Void>{

    @Override
    protected Void doInBackground(Void... params) {
        try {
            sConnection = new SConnection();
            for(Profession p : sConnection.getPlansPreg())
                manager.insertProfession(p.getCode(),p.getName(),"PRE");
            for(Profession p : sConnection.getPlansPos())
                manager.insertProfession(p.getCode(),p.getName(),"POS");

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        Toast.makeText(getApplicationContext(),"Se han cargador todos los planes",Toast.LENGTH_SHORT).show();
    }

}

}

The exception is: Cannot resolve constructor

'(Landroid/context/Context;ILandroid/database/Cursor;[Ljava/lang/String;[II)V

Answers


The constructor you are using was added in API level 11, so it's no wonder it doesn't exist in Android 2.3.6 (API level 10).

public SimpleCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to, int flags) Added in API level 11

Standard constructor.

Parameters

context The context where the ListView associated with this SimpleListItemFactory is running

layout resource identifier of a layout file that defines the views for this list item. The layout file should include at least those named views defined in "to"

c The database cursor. Can be null if the cursor is not available yet.

from A list of column names representing the data to bind to the UI. Can be null if the cursor is not available yet.

to The views that should display column in the "from" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the from parameter. Can be null if the cursor is not available yet.

flags Flags used to determine the behavior of the adapter, as per CursorAdapter(Context, Cursor, int).

See class reference.


Need Your Help

C : Deleting element from Binary Tree

c tree binary segmentation-fault

I have a binary tree with 2 rows: key and combination. Problem appears when I try to delete elements where combination is longer then 5 digits.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.