why android cant find class Mission in dataBase -
i create android application show list of mission data data base database manager ...but have error tell me there no table mission in database
public class dbasemanager extends sqliteopenhelper { private dbasemanager mdbhelper; private sqlitedatabase mdb; public static final string db_name = "si.db"; public static final string db_path = environment.getexternalstoragedirectory() +"/si/db/"; //**********************************table_missions************************************** private static final string table_missions = "missions"; private static final string col_id_mission = "idmission"; private static final int num_col_id_mission = 0; private static final string col_nom_mission = "nommission"; private static final int num_col_nom_mission = 1; private static final string col_date_mission = "datemission"; private static final int num_col_date_mission = 2; private static final string create_missions = "create table " + table_missions + " (" + col_id_mission + " integer primary key autoincrement, " + col_nom_mission + " text not null, " + col_date_mission + " text not null);"; //**************************************************************** public dbasemanager(context context) { super(context, db_name, null, 1); file folder = new file(environment.getexternalstoragedirectory() + "/si/"); if (!folder.exists()) {folder.mkdir();} file dbfolder = new file(environment.getexternalstoragedirectory() + "/si/db/"); if (!dbfolder.exists()) {dbfolder.mkdir();} file photofolder = new file(environment.getexternalstoragedirectory() + "/si/pic/"); if (!photofolder.exists()) {photofolder.mkdir();} } public sqlitedatabase opendatabase() throws sqlexception { sqlitedatabase dbretour = null; try { dbretour = sqlitedatabase.openorcreatedatabase(db_path+ db_name, null); dbretour.execsql(create_points); dbretour.execsql(create_missions); dbretour.execsql(create_releveur); } catch (exception e) {} return dbretour; } public void open(context context) { mdbhelper = new dbasemanager(context); mdb = mdbhelper.getwritabledatabase(); mdb = mdbhelper.opendatabase(); } /** * close database */ @override public void close() { mdb.close(); } public list<missions> getallmissions() { list<missions> mission = new arraylist<missions>(); cursor cursor = mdb.query(dbasemanager.table_missions, allmissions, null, null, null,null,null); cursor.movetofirst(); while (!cursor.isafterlast()) { missions missions = cursortomissions(cursor); mission.add(missions); cursor.movetonext(); } // make sure close cursor cursor.close(); return mission; } private missions cursortomissions(cursor cursor) { missions missions = new missions(null, null); missions.setnommission(cursor.getstring(1)); missions.setdatemission(cursor.getstring(2)); return missions; } @override public void oncreate(sqlitedatabase db) { // todo auto-generated method stub } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // todo auto-generated method stub } }
this missions class
public class missions { private string nommission; private string datemission; public missions(string nommission,string datemission) { this.nommission=nommission; this.datemission=datemission; } public string getnommission() { return nommission; } public void setnommission(string nommission) { this.nommission = nommission; } public string getdatemission() { return datemission; } public void setdatemission(string datemission) { this.datemission = datemission; } @override public string tostring() { return "missions [idmission=" + ", nommission=" + nommission + ", datemission=" + datemission + "]"; } }
and activity in wich show list of missionw
public class missionact extends listactivity { private dbasemanager datasource; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.addmission_activity); datasource = new dbasemanager(this); datasource.open(getbasecontext()); list<missions> values = datasource.getallmissions(); arrayadapter<missions> adapter = new arrayadapter<missions>(this, android.r.layout.simple_list_item_1, values); setlistadapter(adapter); } }
and log
04-23 01:28:21.061: e/androidruntime(12607): fatal exception: main 04-23 01:28:21.061: e/androidruntime(12607): java.lang.runtimeexception: unable start activity componentinfo{tn.pfe.ybn.sigl/tn.pfe.ybn.sigl.missionact}: android.database.sqlite.sqliteexception: no such table: missions: , while compiling: select idmission, nommission, datemission missions 04-23 01:28:21.061: e/androidruntime(12607): caused by: android.database.sqlite.sqliteexception: no such table: missions: , while compiling: select idmission, nommission, datemission missions
did remember update manifest file include activity?
Comments
Post a Comment