Answer the question
In order to leave comments, you need to log in
Android (CursorLoader if cursor=null)?
Help people find a solution.
I have an empty database at the initial moment, respectively Cursor = null, while the application crashes
Help me find a solution.
Dump Stack
this AsyncTaskLoader $ LoadTask (id = 830023124712)
done CountDownLatch (id = 830023124872)
mFuture AsyncTask $ 3 (id = 830023124800)
mStatus AsyncTask $ Status (id = 830013473536)
mTaskInvoked AtomicBoolean (id = 830023124760)
mWorker AsyncTask $ 2 (id = 830,023,124,776)
result SQLiteCursor (id=830023131016)
mClosed false
mColumnNameMap null
mColumns String[14] (id=830023131696)
mContentObservable ContentObservable (id=830023131192)
mContentResolver null
-1
mCount mCurrentRowID null
mDataSetObservable DataSetObservable (id = 830023131152)
mDriver SQLiteDirectCursorDriver (id = 830023130248)
mEditTable "orders" (id = 830023108288)
mExtras Bundle (id = 830013475456)
mNotifyUri null
mPos -1
mQuery SQLiteQuery (id = 830023130328)
mRowIdColumnIndex 0
mSelfObserver null
mSelfObserverLock Object (id=830023131232)
mSelfObserverRegistered false
mStackTrace DatabaseObjectNotClosedException (id=830023131304)
mUpdatedRows HashMap (id=830023131248)
mWindow null
this$0 FragmentOrdersNew$MyCursorLoader (id=2360883)
waiting false
Method responsible for forming the list
private void getData(){
db=new DB(getActivity());
db.open();
c = db.getData(orderStatus);
lm = getLoaderManager();
lm.initLoader(0, null, this);
if(c!=null && c.getCount()>0){
while(c.moveToNext()){
String[] from = new String[] {DB.COLUMN_EXT_ID};
int[] to = new int[] {R.id.tvExId};
adapter = new CustomAdapterOrders(getActivity(), R.layout.orders_list, c, from, to,lm,db,orderStatus,tehGuid,tehToken);
setListAdapter(adapter);
}
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
// TODO Auto-generated method stub
return new MyCursorLoader(getActivity(), db);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
// TODO Auto-generated method stub
adapter.swapCursor(c);
}
@Override
public void onLoaderReset(Loader<Cursor> arg0) {
// TODO Auto-generated method stub
adapter.swapCursor(null);
}
static class MyCursorLoader extends CursorLoader {
DB db;
public MyCursorLoader(Context context, DB db) {
super(context);
this.db = db;
}
@Override
public Cursor loadInBackground() {
//В начальный момент база данных пустая
c = db.getData(orderStatus);
return c;
}
}
Answer the question
In order to leave comments, you need to log in
using the telepathic method:
#ls -l /var/spool/clientmqueue/
.... many many files that the senmail
solution generates (if the idea is guessed)
PS although of course /usr/... :( I'll
#du -cs /* | sort -n
...
1342636 /usr
12364008 /var
15006492 total
#du -cs /var/* | sort -n
...
1768308 /var/log
9570600 /var/lib
12364020 total
#du -cs /var/lib/* | sort -n
Adapter is empty because.
In the getData method, you get the Cursor and initialize the Loader. Since the Cursor is empty, the if branch fails and adapter is not initialized. The Loader then completes its loading with the onLoadFinished method, which calls adapter.swapCursor(c). adapter is null, so we get a crash.
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
if (adapter != null) {
adapter.swapCursor(c);
}
}
@Override
public void onLoaderReset(Loader<Cursor> arg0) {
if (adapter != null) {
adapter.swapCursor(null);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question