What I'm trying to do is create a table, then enter some values in it and select. The problem I am facing is app preventing unfortunately. I do not know what the problem is.
My code is: This class calls the database handler
increases the public class service events {Personal Static Last String DB_NAME = "EventDB"; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.edit_product); Bundle Extras = Milentant (). GetExtras (); String event = extras .getString ("event"); String date = additional .getString ("date"); String College = Extras .getString ("College"); DatabaseHandler db = new databank (getApplicationContext ()); Db.insert_data (event, date, college); String c = db.select_data (); Toast. Make text (getApplicationContext), "EventName:" + c + "", Toast. LNNHHLANG). Show (); }}
database handler
public class database bundler SQLiteOpenHelper extended {personal constant end-end DATABASE_VERSION = 1; Private static final string DATABASE_NAME = "EventDB"; Private static final string TABLE_NAME = "eventlist"; Public databashendler (reference reference) {super (references, database, ANN, blank, databasebessons); } @ Override Creates on Public Zero (SQLiteDatabase db) {// Category Table query string CREATE_ITEM_TABLE; CREATE_ITEM_TABLE = "Create table event (event name varchar (100), event varchar (100), college varchar (100));"; Db.execSQL (CREATE_ITEM_TABLE); } @ Override Public Wide On Upgrade (SQLiteDatabase DB, Int JuniorWarson, Int Newversion) {} Zero Insert DataData (String EventName, String Date, String College) {SQLiteDatabase = DB = this.getWritableDatabase (); Material values = new material value (); Values.put ("eventname", eventname); Values.put ("EVENTDATE", date); Values.put ("college", college); Db.insert (TABLE_NAME, null, value); Db.close (); } Public string select_data () {SQLiteDatabase db = this.getWritableDatabase (); String selectQuery = "Select event from event list where eventname = 'techcontest'"; String c = faucet; Cursor cursor = db.rawQuery (selectQuery, zero); Cursor.moveToFirst (); C = cursor.getString (0); Return c; }}
Shows my logs
03-16 20: 00: 19.116 8378-8378 / com.example.android E / SQLiteLog: (1 ) There is no such table: eventlist 03-16 20: 00: 19.122 8378-8378 / Com. Examples. Android E / SQLite Database: College = ACS University eventdate = 2-02-15 eventname = error in inserting techocontest android.database.sqlite.SQLiteException: EventList (code1): EventList (code1):, while compiled: Enter the Eventilist (College, event, eventmeam) value (?,?,?)
Do not think that you are closing the database in the select_data () method.
No comments:
Post a Comment