I am getting a number of a listview with which I show a Dialog data item associated with that number but giving me this error everytime I try to get the data in this case the product name
Other data is that mNum receive a 11-digit number or less
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.dialog_frag, container, false);
mNum = getArguments().getString("num");
//receiving number as a search in mNum
manager = new DBProducManager(rootView.getContext());
cursor = manager.getItem(mNum);
getDialog().setTitle("Num "+ mNum);
Log.i("HELLO ","THE NAME IS: "+ cursor.getString(cursor.getColumnIndex(cursor.getColumnName(2))));
// show on log the name of the column name
return rootView;
}
Here's the code Manager
public Cursor getItem(String id){
String buildSql = "SELECT * FROM " + TABLE_NAME +" WHERE " + CNP_ID +" = "+ id;
return db.rawQuery(buildSql,null);
}
And the error log
11-27 15:56:22.941 2109-2109/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.fragments.adaptervent, PID: 2109
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 0
Aucun commentaire:
Enregistrer un commentaire