I am getting first Fatal Exception in main , and then a No such table found Exception in my application . I know this type of questions have already been asked before but if anyone can give a specific answer to my problem , would be very great. My code is :
public class driverdb extends SQLiteOpenHelper {
public static final String DB_NAME = "driver";
public static final int DB_VERSION = 2;
public static final String TABLE = "driver";
public static final String _ID = "_id";
public static final String DRIVERNAME = "drivername";
public static final String DRIVERMOBILENO = "drivermobileno";
public static final String LICENSENO = "licenseno";
public static final String BASENO = "baseno";
public static final String CREATE = "create table " + TABLE + "(" + _ID
+ "Integer primary key autoincrement," + DRIVERNAME + "text,"
+ DRIVERMOBILENO + "text," + LICENSENO + "text ," + BASENO
+ "text)";
SQLiteDatabase db;
Context context;
public driverdb(Context context) {
super(context, DB_NAME, null, DB_VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
public void readdata() {
db = getReadableDatabase();
}
public void writedata() {
db = getWritableDatabase();
}
public void close() {
db.close();
}
public long Insert(drivermodel e1) {
ContentValues cv = new ContentValues();
cv.put(DRIVERNAME, e1.getDrivername());
cv.put(DRIVERMOBILENO, e1.getDrivermobileno());
cv.put(LICENSENO, e1.getLicenseno());
cv.put(BASENO, e1.getBaseno());
long d = db.insert(TABLE, null, cv);
return d;
}
public Cursor getdata() {
try {
return db.query(TABLE, new String[] { _ID, DRIVERNAME,
DRIVERMOBILENO, LICENSENO, BASENO }, null, null, null,
null, null);
} catch (SQLException e) {
// TODO: handle exception
Log.e("Exception on query", e.toString());
return null;
}
}
}
And error is on line 74 and 49. please if anyone can give a specific solution would be very helpful.
Aucun commentaire:
Enregistrer un commentaire