I'm trying to open database as follows :
SQLiteDatabase myDatabase;
myDatabase = openOrCreateDatabase("sudoku.db", Context.MODE_PRIVATE, null);
This code works fine when I implement it in the Service class, but when I try to implement this in the onPostExecute eventhandler of the GeneraterThread class,implementing AsyncTask, I get the following error :
The method openOrCreateDatabase(String, int, null) is undefined for the type GeneraterThread
It looks like your just set wrong arguments for function.
There are these definitions in SDK:
public static SQLiteDatabase openOrCreateDatabase (String path, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler)
public static SQLiteDatabase openOrCreateDatabase (String path, SQLiteDatabase.CursorFactory factory)
public static SQLiteDatabase openOrCreateDatabase (File file, SQLiteDatabase.CursorFactory factory)
But your calling that function is wrong.
Maybe you wanted to call openDatabase (String path, SQLiteDatabase.CursorFactory factory, int flags)
?
In this case you just set arguments in wrong order - you're doing
openOrCreateDatabase("sudoku.db", Context.MODE_PRIVATE, null); //WRONG
instead:
openDatabase("sudoku.db", null, Context.MODE_PRIVATE); //RIGHT
It looks like you're trying to invoke openOrCreateDatabase method on GeneraterThread instance which doesn't have the method (and Service class has the method). You probably may pass in a reference to a Context object and invoke the method on it. Or use static method of SQLiteDatabase.openOrCreateDatabase().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With