Edit: I tried this on my phone and it works, can anyone tell me why it does not work on an emulator?
I am trying to open a database on android, but it is throwing an
Why are you keeping code complex try this
public SQLiteDatabase sampleDB;
public String COLUMN_ID="_id";
public String COLUMN1="username";
public String COLUMN2="password";
public String TABLE_NAME="Androdata";
sampleDB = this.openOrCreateDatabase(TABLE_NAME, MODE_PRIVATE, null);
private void insertDB() {
sampleDB.execSQL("INSERT INTO " +
TABLE_NAME +
" Values ('1','Androviewer','viewer');");
System.out.println("Inserted data successfully....");
}
private void createDB() {
sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " +
TABLE_NAME+ "(" + COLUMN_ID
+ " integer primary key autoincrement, " + COLUMN1
+ " text not null,"+ COLUMN2
+ " text not null);");
System.out.println("Database created successfully....");
}