android - Error: table fact_info has no column named rating -


public class databaseoperations extends sqliteopenhelper {  public static final int database_version =1; public string create_query = "create table "+ tabledata.tableinfo.table_name + " (" + tabledata.tableinfo.fact_+" text,"+ tabledata.tableinfo.rating_value+"integer );";  public databaseoperations(context context) {     super(context, tabledata.tableinfo.database_name, null, database_version);     log.d("database operations","database created"); }  @override public void oncreate(sqlitedatabase sdb) {     sdb.execsql(create_query);     log.d("database operations","table created");  }  @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {  }  public void putinformation(databaseoperations dop, string fact, int rating){      sqlitedatabase sq = dop.getwritabledatabase();     contentvalues cv = new contentvalues();      cv.put(tabledata.tableinfo.fact_,fact);     cv.put(tabledata.tableinfo.rating_value ,rating);     long k = sq.insert(tabledata.tableinfo.table_name, null, cv);     log.d("database operations", "one row inserted");  }  public cursor getinformation(databaseoperations dop){     log.d("database operations", "one row inserted");     sqlitedatabase sq = dop.getreadabledatabase();     log.d("database operations", "one row inserted");     string[] columns ={tabledata.tableinfo.fact_, tabledata.tableinfo.rating_value};     cursor cr = sq.query(tabledata.tableinfo.table_name,columns,null,null,null,null,null);     return cr; }  } 

the logcat error message keep getting is, cant figure out wrong create query code, have tried changing type integer, numeric , real:

8305-8305/com.danial.funfacts e/sqlitelog﹕ (1) table fact_info has no column named rating  android.database.sqlite.sqliteexception: table fact_info has no column named rating (code 1): , while compiling: insert fact_info(rating,facts) values (?,?) 

you missing space after column name , before type:

public string create_query = "create table " + tabledata.tableinfo.table_name + " ("      + tabledata.tableinfo.fact_ + " text,"     + tabledata.tableinfo.rating_value + " integer);";                                           ^ 

you current code produces column named "ratinginteger" no type affinity.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -