This line of code gives me error in the phrase SQLiteDatabase.CREATE_IF_NECESSARY
and prevents me from doing the database. Why is this happening?
SQLiteDatabase BaseDados=SQLiteDatabase.openOrCreateDatabase("BaseDados",SQLiteDatabase.CREATE_IF_NECESSARY,null);
The error you give is as follows:
Error: (16, 54) error: no suitable method found for openOrCreateDatabase (String, int,) method SQLiteDatabase.openOrCreateDatabase (String, CursorFactory, DatabaseErrorHandler) is not applicable (current argument int can not be converted to CursorFactory by method invocation conversion) method SQLiteDatabase.openOrCreateDatabase (String, CursorFactory) is not applicable (actual and formal argument lists differ in length) method SQLiteDatabase.openOrCreateDatabase (File, CursorFactory) is not applicable (current and formal argument lists differ in length)
The code I made is as follows:
public class GestorBaseDados {
Context contexto;
SQLiteDatabase BD;
public GestorBaseDados(Context cont) {
contexto=cont;
String erro=null;
try {
BD=SQLiteDatabase.openOrCreateDatabase("BaseDados",SQLiteDatabase.CREATE_IF_NECESSARY,null);
}catch (Exception e)
{
Toast.makeText(contexto,"erro "+e.toString(),Toast.LENGTH_LONG).show();
}
}
}
This is a class that will have all the methods to tinker with the database.