i have created a class for creating database in android, but there are some compilation errors in this…..
I am not able to identify why these errors are coming.. My Code is
public DbHelper(Context ctx) {
try {
db = ctx.openDatabase(DATABASE_NAME,null);
} catch (FileNotFoundException e) {
try {
db =
ctx.createDatabase(DATABASE_NAME, DATABASE_VERSION, 0,
null);
db.execSQL(DATABASE_CREATE);
} catch (FileNotFoundException e1) {
db = null;
}
}
}
When i am opening database with “Context” object , it is giving me error that “openDatabase” method is undefined. ?
This link explains open and create database methods and how to create database class. Similarly you need to create your class.Try using it!