android-cursor

java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToFirst()' on a null object reference [duplicate]

你。 提交于 2019-12-24 08:11:56
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 2 years ago . I'm creating an app that list all images in my phone and I'm using media content provider to do it. my problem is I always get this error in my app wherever i run it. 08-28 00:31:27.001 16706-16706/com.chill.leoj.burp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.chill.leoj.burp, PID: 16706 java.lang.RuntimeException: Unable to start activity ComponentInfo{com

ContactsContract select records by phone number

风格不统一 提交于 2019-12-24 07:16:02
问题 I can select all contacts using the query below cr = mActivity.getContentResolver(); String selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " > 0"; String orderBy = ContactsContract.Contacts.DISPLAY_NAME + " ASC "; Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, selection, null, orderBy); However, I have a phone number list and I want to create this query like String selection = ContactsContract.Contacts.PhoneNumber_or_something_else in (MyPhoneNumberArray) Is that

InsertAPN() Method Does Not Write APN Settings - Android 2.3.6

纵饮孤独 提交于 2019-12-24 06:58:21
问题 I have an android application which is supposed to write new APN settings to a device however every time I run the application the new APN settings do not appear to be written to the device (the APN settings are totally blank after execution) I belive this may have something to do with a problem with InsertAPN() [shown below] however I'm unable to determine the root cause of the issue. P.S. Any debugging tips/questions are greatly appreciated. SOURCE SNIPPET: /* * Insert a new APN entry into

Android “attempted to access a cursor after it has been closed”

非 Y 不嫁゛ 提交于 2019-12-24 03:44:09
问题 I'm trying to adapt the HelloGridView example so that I can show image thumbnails of images stored on the SD instead of images in the res/drawable. The idea is to create a list with the images first in the ImageView.initialize() function and the use it pretty much exactly as in the example. I'm having trouble with my cursor, first I tried to have it as private in the Imageview.initialize() function (it's only commented away so you can see where I had it) since to me it seems like it is only

Android “attempted to access a cursor after it has been closed”

空扰寡人 提交于 2019-12-24 03:44:06
问题 I'm trying to adapt the HelloGridView example so that I can show image thumbnails of images stored on the SD instead of images in the res/drawable. The idea is to create a list with the images first in the ImageView.initialize() function and the use it pretty much exactly as in the example. I'm having trouble with my cursor, first I tried to have it as private in the Imageview.initialize() function (it's only commented away so you can see where I had it) since to me it seems like it is only

Turn SQLite columns to rows

帅比萌擦擦* 提交于 2019-12-24 01:22:44
问题 I am trying to convert a query which returns a single row with multiple columns to multiple rows with one or multiple columns. As an example my query looks like the following visualized: SELECT _id, value1, value2, value3, value4 FROM table WHERE _id IS 1; RESULT: _id value1 value2 value3 value4 ---------------------------------------- 1 10 11 12 13 I would like to have my results look like the following: name value -------------- value1 10 value2 11 value3 12 value4 13 but I can also work

Using pagination with CursorLoader and MergeCursor closes old cursors

怎甘沉沦 提交于 2019-12-22 00:38:43
问题 As the title says, when trying to paginate a ListView backed by a SimpleCursorAdapter and a CursorLoader , old cursors are getting closed, thus the below exception is being thrown. The first 2 pages load just fine (the first isn't using the MergeCursor and the second page is the first one to use the MergeCursor ). I don't call any close() on any cursor whatsoever. What is interesting is that while debugging, I cannot see the closed flags on any cursor being set as true, for what it's worth.

When to close Cursor used in SimpleCursorAdapter

倖福魔咒の 提交于 2019-12-21 07:42:14
问题 I'm using a SimpleCursorAdapter to display results in a ListView but since I've got to query my database lots of times during a search (using the SearchView widget) it worries me that the cursor might be left opened. This is how I query my database and show the results in a ListView: class SearchCustomers extends AsyncTask<String,Void,Cursor>{ @Override protected Cursor doInBackground(String... params) { //get the query String query=params[0].toLowerCase(Locale.getDefault()); Cursor cursor

When to close Cursor used in SimpleCursorAdapter

风流意气都作罢 提交于 2019-12-21 07:41:15
问题 I'm using a SimpleCursorAdapter to display results in a ListView but since I've got to query my database lots of times during a search (using the SearchView widget) it worries me that the cursor might be left opened. This is how I query my database and show the results in a ListView: class SearchCustomers extends AsyncTask<String,Void,Cursor>{ @Override protected Cursor doInBackground(String... params) { //get the query String query=params[0].toLowerCase(Locale.getDefault()); Cursor cursor

Android database - Cannot perform this operation because the connection pool has been closed

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 07:15:11
问题 I have strange problem with android database and cursors. Time to time (very rarely) happens, that I got crash report from customers. It's hard to find out why it crashes, as I have ~ 150 000 active users and maybe 1 report per week or so, so it's really some minor bug. Here is exception: STACK_TRACE=java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed. at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked