- 1

Caused by: java.lang.IllegalArgumentException: column '_id' does not exist. Available columns: [RaagName]

package com.example.raagmalaapplication.adapterpack; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.icu.text.Transliterator; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.SimpleCursorAdapter; import android.widget.TextView; import android.widget.Toast; //import androidx.room.parser.expansion.Position; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.example.raagmalaapplication.R; import com.example.raagmalaapplication.applicationclasses.all; import com.example.raagmalaapplication.model.allraagview; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class allragasadapter { DatabaseHelper helper; SQLiteDatabase db; Context context; public allragasadapter(Context context) { helper = new DatabaseHelper(context); db = helper.getWritableDatabase(); this.context = context; } public SimpleCursorAdapter getAllRaags(){ String columns[]={DatabaseHelper.key_RaagNames}; Cursor cursor = db.query(DatabaseHelper.tbl,columns,null,null,null,null,null); String[] allragas = new String[]{ DatabaseHelper.key_RaagNames }; int[] toViewAllRaagas = new int[]{R.id.txtraagas}; SimpleCursorAdapter allRaagView = new SimpleCursorAdapter( context, R.layout.all_raga_display, cursor, allragas, toViewAllRaagas ); return allRaagView; } private class DatabaseHelper extends SQLiteOpenHelper { private static final String dbname = "RaagDB.db"; private static final String tbl = "RaagDetails"; private static final St

2nd May 2022, 6:41 PM
Chinmayi Dongre
Chinmayi Dongre - avatar
2 Réponses
+ 1
About IllegalArgumentException: Thrown to indicate that a method has been passed an illegal or inappropriate argument. https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html If you read the error message you will find which method has thrown this exception and in which line. Goto this line and check the arguments of the method call. You may need to read the description (e.g.java docs) again to see how the method should be used and what arguments are allowed.
2nd May 2022, 7:18 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
also check columns in used database, why expected column '_id' is not there
3rd May 2022, 6:28 PM
zemiak