0

I'm trying to develop a student management android app. But when I try to test it using my phone, it displays that my app has unfortunately stopped. I've tried to find errors and try to test my app while I coding. When I code the database and table creating codes, app has stopped. Please if someone can help me I highly appreciate it.

package com.example.kash.myapp;

    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;

    public class MainActivity extends AppCompatActivity implements View.OnClickListener {


        EditText editName, editRollno, editMarks;
        Button btnAdd, btnDelete, btnModify, btnView, btnViewAll, btnShowInfo;
        SQLiteDatabase db;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            editName = (EditText) findViewById(R.id.editName);
            editRollno = (EditText) findViewById(R.id.editRollno);
            editMarks = (EditText) findViewById(R.id.editMarks);

            btnAdd = (Button) findViewById(R.id.btnAdd);
            btnDelete = (Button) findViewById(R.id.btnDelete);
            btnModify = (Button) findViewById(R.id.btnModify);
            btnView = (Button) findViewById(R.id.btnView);
            btnViewAll = (Button) findViewById(R.id.btnViewAll);
            btnShowInfo = (Button) findViewById(R.id.btnShowInfo);

            btnAdd.setOnClickListener(this);
            btnDelete.setOnClickListener(this);
            btnModify.setOnClickListener(this);
            btnView.setOnClickListener( this);
            btnViewAll.setOnClickListener( this);
            btnShowInfo.setOnClickListener(this);

            db = openOrCreateDatabase("studentsdb", Context.MODE_PRIVATE, null);
            db.execSQL("CREATE TABLE IF NOT EXITS students(name VARCHAR, rollno VARCHAR, marks VARCHAR);");

        }

        @Override
        public void onClick(View view) {

        }
    }
Phantômaxx
  • 36,442
  • 21
  • 78
  • 108
Kash
  • 309
  • 2
  • 12

1 Answers1

0

Your app crashes due to Syntax error exception. You have a mistake in word EXITS, change it to EXISTS

 db.execSQL("CREATE TABLE IF NOT EXISTS students(name VARCHAR, rollno VARCHAR, marks VARCHAR);");
Ayaz Alifov
  • 6,718
  • 4
  • 49
  • 50