我正在使用SQLite数据库并希望在不使用的情况下加载它ContentProvider.
我无法使用我的子类SimpleCursorLoader(从没有ContentProvider的CursorLoader使用中获取)来使用LoaderManager.
在覆盖的方法
@Override
public Loader<Cursor> onCreateLoader(int ID, Bundle args) {
return new ListCursorLoader(this, dBHelper);
}
Run Code Online (Sandbox Code Playgroud)
我得到一个类型不匹配,说它无法转换ListCursorLoader为Loader<Cursor>.我已尝试动态创建ListCursorLoader(即在方法中),但这也不起作用.
这是我的代码ListCursorLoader:
package utilities;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
public class ListCursorLoader extends SimpleCursorLoader {
private DBAdapter dBAdapter;
public ListCursorLoader(Context context, DBAdapter adapter) {
super(context);
dBAdapter = adapter;
}
@Override
public Cursor loadInBackground() {
Cursor cursor = null;
dBAdapter.open();
try {
cursor = dBAdapter.getAllQueries();
} catch (SQLException e) { …Run Code Online (Sandbox Code Playgroud)