-3
private static final String dbname="student.db";
private static final String tblname="detail";
private static final String c1="uname";
private static final String c2="id";
private static final String c3="pass";
private static final String c4="add";
private static final String c5="gender";
private static final String c6="sequrity";
private static final String c7="answer";


public Databasehelper(Context context) 
{
    super(context, dbname, null, 1);

}

@Override
public void onCreate(SQLiteDatabase db) 
{
    String q= "create table "+tblname+"("
        +c1+" varchar(10),"
        +c2+" varchar(20),"
        +c3+" varchar(10),"
        +c4+" varchar(100),"
        +c5+" varchar(10),"
        +c6+" varchar(100),"
        +c7+" varchar(10))";

        db.execSQL(q);
}

in above coding in create table define Error

laalto
  • 150,114
  • 66
  • 286
  • 303
Jadav Ramesh
  • 11
  • 1
  • 7
  • 1
    share you error log –  Oct 27 '17 at 05:00
  • it not define Error but when i run avd than my application is unfortunatlly stoped ... chaek mya create table query is right or not – Jadav Ramesh Oct 27 '17 at 05:02
  • Suggestion: Use the Room library. https://developer.android.com/topic/libraries/architecture/room.html – OneCricketeer Oct 27 '17 at 05:03
  • There **is** an error. https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – OneCricketeer Oct 27 '17 at 05:04
  • when i run this project it create only database not create table – Jadav Ramesh Oct 27 '17 at 05:05
  • just when your application is crashed go to Android monitor on the bottom of your android studio screen and paste what's on your logcat here. –  Oct 27 '17 at 05:05
  • 1
    Please [edit] your question with your logs. Also, you will want to clear the application data. For more information. https://stackoverflow.com/questions/21881992/when-is-sqliteopenhelper-oncreate-onupgrade-run – OneCricketeer Oct 27 '17 at 05:06
  • please don't edit your question to be something completely different, rendering any older comments or answers obsolete – laalto Oct 27 '17 at 08:40

2 Answers2

0

You can update your query with this

"create table "+tblname+"("+c1+" TEXT, "+c2+" TEXT, "+c3+" TEXT, "+c4+" TEXT, "+c5+" TEXT, "+c6+" TEXT, "+c7+" TEXT)";

In SQLite TEXT is same as VARCHAR you can use TEXT as this answer.

You can also check commonly asked quetions for sqlite here

Lalit Jadav
  • 1,409
  • 1
  • 15
  • 38
0

add is a sqlite keyword. As such it cannot be used as an identifier such as a column name.

Rename that column to something that is not a keyword.

laalto
  • 150,114
  • 66
  • 286
  • 303