方法openOrCreateDatabase(String,int,null)是未定义的 [英] The method openOrCreateDatabase(String, int, null) is undefined
问题描述
我正在尝试如下打开数据库:
I'm trying to open database as follows :
SQLiteDatabase myDatabase;
myDatabase = openOrCreateDatabase("sudoku.db", Context.MODE_PRIVATE, null);
当我在Service类中实现此代码时,它工作正常,但是当我尝试在GeneraterThread类的onPostExecute事件处理程序中实现AsyncTask时,实现以下错误:
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 :
对于类型GeneratorrThread
推荐答案
您似乎正在尝试在不具有该方法(而Service类具有该方法)的GeneraterThread实例上调用openOrCreateDatabase方法.您可能会传递对Context对象的引用并在其上调用方法.或使用SQLiteDatabase.openOrCreateDatabase()的静态方法.
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().
这篇关于方法openOrCreateDatabase(String,int,null)是未定义的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!