java - Loading data from cursor crashing onLoadFinished -


in application retrieving contact data using loader. have debugged application , find application crashes on first statement occurs in onloadfinished callback.

here code:

@override public void onloadfinished(loader<cursor> arg0, cursor arg1) {     log.d("loader","load finished");     madapter.changecursor(arg1);      phonenumber_enter.setadapter(madapter);  } 

i finding application crashes on first line in callback(in case application crashes when message logged). here logcat:

02-05 21:31:07.357: e/androidruntime(31707): java.lang.runtimeexception: error occured while executing doinbackground() 02-05 21:31:07.357: e/androidruntime(31707):    @ android.support.v4.content.modernasynctask$3.done(modernasynctask.java:137) 02-05 21:31:07.357: e/androidruntime(31707):    @ java.util.concurrent.futuretask.finishcompletion(futuretask.java:355) 02-05 21:31:07.357: e/androidruntime(31707):    @ java.util.concurrent.futuretask.setexception(futuretask.java:222) 02-05 21:31:07.357: e/androidruntime(31707):    @ java.util.concurrent.futuretask.run(futuretask.java:242) 02-05 21:31:07.357: e/androidruntime(31707):    @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) 02-05 21:31:07.357: e/androidruntime(31707):    @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) 02-05 21:31:07.357: e/androidruntime(31707):    @ java.lang.thread.run(thread.java:841) 02-05 21:31:07.357: e/androidruntime(31707): caused by: java.lang.illegalargumentexception: invalid column data1 02-05 21:31:07.357: e/androidruntime(31707):    @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:167) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:137) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.content.contentproviderproxy.query(contentprovidernative.java:413) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.content.contentresolver.query(contentresolver.java:461) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.content.contentresolver.query(contentresolver.java:404) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.support.v4.content.cursorloader.loadinbackground(cursorloader.java:49) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.support.v4.content.cursorloader.loadinbackground(cursorloader.java:35) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.support.v4.content.asynctaskloader.onloadinbackground(asynctaskloader.java:242) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.support.v4.content.asynctaskloader$loadtask.doinbackground(asynctaskloader.java:51) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.support.v4.content.asynctaskloader$loadtask.doinbackground(asynctaskloader.java:40) 02-05 21:31:07.357: e/androidruntime(31707):    @ android.support.v4.content.modernasynctask$2.call(modernasynctask.java:123) 02-05 21:31:07.357: e/androidruntime(31707):    @ java.util.concurrent.futuretask.run(futuretask.java:237) 

i see there no data1 column shouldn't make difference because cursor loader created follows:

@override public loader<cursor> oncreateloader(int arg0, bundle arg1) {     return new cursorloader(getactivity(),             contactscontract.contacts.content_uri, null, null, null,             null); } 

since projection null thought possible columns selected. after debugging, found there no column in cursor called data1. thoughts appreciated.

edit: have tested application , seems crash doesnt occur when have debugger attached application. though no cursor returned seems loader not correctly working.

edit 2: ok debugged application again , saw columns cursor returning. no column contains phone numbers. here original statement:

cursorloader(getactivity(),             contactscontract.contacts.content_uri, null, null, null, null); 

any ideas?

ok after messing around found original statement incorrect(i querying wrong database). changed from:

cursorloader(getactivity(),         contactscontract.contacts.content_uri, null, null, null, null); 

to

cursorloader(getactivity(),             contactscontract.commondatakinds.phone.content_uri, null, null,             null, null); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -