java - Cannot isert data into database - android -
i'm trying insert "favorites" database im getting error in log cat cannot understand. can me solve issue?
here code call in activity:
private static final string database_create_favorites = "create table " + table_favorites + "(" + category + " text, " + title_en + " text, " + title_fr + " text, " + title_ar + " text," + description_en + "text," + description_fr + "text," + description_ar + "text," + description_ph + "text, primary key (" + category + ", " + title_en + ") );"; public long addfavorite(myobject object) { contentvalues values = new contentvalues(); values.put(category, object.getcategory()); values.put(title_en, object.gettitleen()); values.put(title_fr, object.gettitlefr()); values.put(title_ar, object.gettitlear()); values.put(description_en, object.getdescriptionen()); values.put(description_fr, object.getdescriptionfr()); values.put(description_ar, object.getdescriptionar()); values.put(description_ph, object.getdescriptionph()); // inserting row return database.insert(table_favorites, null, values); }
and in logcat:
06-01 15:12:10.745: e/sqlitedatabase(6766): error inserting titlefr=1 - lorsqu'on se réveille category=home & family description_ph=lâ ilâha illâ l-lâhu wahdahu lâ sharîka lahu, lahu-l-mulku wa lahu lhamdu, wa huwa calâ kulli shay’in qadîr. subhâna l-lâhi, wa-l-hamdu li-l-lâhi, wa lâ ilâha illa l-lâhu, wa l-lâhu akbaru, wa lâ hawla wa lâ quwwata illa bi-l-lâhi-l-caliyyi-l-cazîm. rabbi ghfir lî description_ar=يَا أَيُّهَا الَّذِينَ آمَنُوا اذْكُرُوا اللهَ ذِكْرًا كَثِيراً description_en=o believe, remember allah rememberance titlear=1 - أذكار الاستيقاظ من النوم description_fr=o vous qui croyez ! evoquez allah d’une façon abondante titleen=1 - when waking 06-01 15:12:10.745: e/sqlitedatabase(6766): android.database.sqlite.sqliteexception: table favorites has no column named description_ph: , while compiling: insert favorites(titlefr,category,description_ph,description_ar,description_en,titlear,description_fr,titleen) values (?,?,?,?,?,?,?,?) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqlitecompiledsql.native_compile(native method) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqlitecompiledsql.<init>(sqlitecompiledsql.java:68) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqliteprogram.compilesql(sqliteprogram.java:143) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqliteprogram.compileandbindallargs(sqliteprogram.java:361) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqlitestatement.acquireandlock(sqlitestatement.java:260) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqlitestatement.executeinsert(sqlitestatement.java:112) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqlitedatabase.insertwithonconflict(sqlitedatabase.java:1718) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.database.sqlite.sqlitedatabase.insert(sqlitedatabase.java:1591) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ com.quanticapps.hisnalmuslim.functions.databasehelper.addfavorite(databasehelper.java:103) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ com.quanticapps.hisnalmuslim.details$4.onclick(details.java:222) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.view.view.performclick(view.java:3534) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.view.view$performclick.run(view.java:14263) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.os.handler.handlecallback(handler.java:605) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.os.handler.dispatchmessage(handler.java:92) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.os.looper.loop(looper.java:137) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ android.app.activitythread.main(activitythread.java:4441) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ java.lang.reflect.method.invokenative(native method) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ java.lang.reflect.method.invoke(method.java:511) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 06-01 15:12:10.745: e/sqlitedatabase(6766): @ dalvik.system.nativestart.main(native method)
your table creation wrong, , table isn't created @ all.:
+ description_en + "text," + description_fr + "text," + description_ar + "text," + description_ph + "text,,primary key ("
while should write:
+ description_en + " text," + description_fr + " text," + description_ar + " text," + description_ph + " text, primary key ("
mind spaces between field names , field types.
Comments
Post a Comment