I am new to SqlLite Database. I have created Database using SqlLite Database Browser
and saved it in Android App Project Folder in path src/com/example/hello/databases/
I have also created tables already. Now, When I am trying to run code, It is showing error no such table found.
My code is as below :
public class DatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 3;
private static final String DATABASE_NAME = "db_admin";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
// Adding User Response When He/She attempts Questions...
void addUserResponse(UserResponse response) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("QId", response.getQId());
values.put("OptionId", response.getOptionId());
values.put("Responsedate", response.getResponseDate());
// Inserting Row
db.insert("tblUserResponse", null, values);
db.close();
}
}
Inserting values as :
DatabaseHandler db = new DatabaseHandler(this);
db.addUserResponse(new UserResponse("1", "1", "hello"));
db.addUserResponse(new UserResponse("2", "1", "hello"));
db.addUserResponse(new UserResponse("3", "3", "hello"));
db.addUserResponse(new UserResponse("4", "2", "hello"));