0
votes

My friends, I made a class called dbmanger and this is my database class and inside the class there is a databasehelper. But for me it shows these two errors

Class "DtaBaseHelper" is never used 
Class "DBmanager" is never usedcode 
Property "context" is never used

code database:

class DBmanager(private val context: Context )
{
private val dbName="notesDB"
    private val tableName="tblNotes"
    private val colID="ID"
    private val colTitle="Title"
    private val colDesc="Desc"
    private val dbVersion=1
    private val sqlCreateTable="CREATE TABLE IF NOT EXISTS "+tableName+"("+colID+" INTEGER PRIMARY KEY ,"+colTitle+" VARCHAR ,"+colDesc+" text );"
   // private val db = DataBA
    inner class DtaBaseHelper(private val context2: Context):SQLiteOpenHelper(context2,dbName,null,dbVersion) {
        override fun onCreate(p0: SQLiteDatabase?) {
            p0?.execSQL(sqlCreateTable)
            Toast.makeText(context2, "دیتــا بیس ایجاد شد ", Toast.LENGTH_SHORT).show()
        }

        override fun onUpgrade(p0: SQLiteDatabase?, p1: Int, p2: Int) {
            if (p0 != null) {
                p0.execSQL("DROP TABLE IF EXISTS $tableName")
            }
        }
    }


}

I haven't written any code in the main activity yet


Guys, what do you think, should I delete Android Studio and install another version? I'm tired, I'm a beginner, now I'm full of mistakes Which Android Studio should I install with which sdk and gradle to have less errors?


Your DBmanager class takes a context parameter in its constructor, but you never use that anywhere inside the class. That's not an error, it's just letting you know so you can remove it, or so it reminds you that you did need it for something. Same with the unused classes - you've written them, but you're not using them, but that won't stop it running. This is fine, but installing a newer version of Android Studio generally won't make any difference when you run into problems - you need to be patient and work out what's happening, because you'll run into stuff sometimes, just how it is - cactustictacs