Questions tagged [android-cursor]

android-cursor is an interface which provides random read-write access to the result set returned by a database query.

android-cursor is an interface which provides random read-write access to the result set returned by a database query.

Cursor provides a way to process data returned from a database, and provide features such as traversing the table, getting a certain row or column, and getting number of rows returned by the database.

It also allows to monitor a URI for changes using the setNotificationUri function, which tells that the data which the cursor has is old and it has to be updated.

Cursor Class Reference

878 questions
51
votes
2 answers

Using String[] selectionArgs in SQLiteDatabase.query()

How do I use the String[] selectionArgs in SQLiteDatabase.query()? I wish I could just set it to null, as I have no use for it. I am just trying to load an entire unsorted table from a database into a Cursor. Any suggestions on how to achieve this?
BenjiWiebe
  • 1,885
  • 3
  • 20
  • 39
44
votes
2 answers

android java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow

I am developing an application which download some files and save their text in file_content field to database. The file sizes can vary from some KBs to 10 MB. The app works for all sizes while saving. The problem occurs when using select statement…
Khawar Raza
  • 14,992
  • 23
  • 63
  • 117
40
votes
5 answers

Is it OK to have one instance of SQLiteOpenHelper shared by all Activities in an Android application?

Would it be OK to have a single instance of SQLiteOpenHelper as a member of a subclassed Application, and have all Activities that need an instance of SQLiteDatabase get it from the one helper?
Julian A.
  • 9,850
  • 12
  • 57
  • 98
36
votes
5 answers

How can I create a list Array with the cursor data in Android

How can I create a list Array (the list display First Alphabet when scroll) with the cursor data?
Dennie
  • 2,561
  • 13
  • 40
  • 40
31
votes
2 answers

Android RecyclerView + CursorLoader + ContentProvider + "Load More"

I have created one Activity in that I am implementing CursorLoader for load data from Database. I have done that thing for all records of that Table but I want to load 30-30 records like Load More Functionality I have tried to create query and its…
31
votes
4 answers

How to disable cursor positioning and text selection in an EditText? (Android)

I'm searching for a way to prevent the user from moving the cursor position anywhere. The cursor should always stay at the end of the current EditText value. In addition to that the user should not be able to select anything in the EditText. Do you…
Louis
  • 2,011
  • 4
  • 17
  • 18
24
votes
4 answers

Cursor.getType() for API Level <11

I'm querying the CallLog content provider and need to detect the column types. In Honeycomb and newer (API Level 11+) you can get a columns preferred data type by calling the method Cursor.getType(int columnIndex) which returns one of the following…
jenzz
  • 7,123
  • 6
  • 46
  • 68
20
votes
6 answers

How to update existing contact?

I have one existing contact, I need to add a work address to that existing contact. I am using the following code, but it's not working. String selectPhone = Data.CONTACT_ID + "=? AND " + Data.MIMETYPE + "='" + …
Baskar
  • 519
  • 2
  • 6
  • 12
20
votes
3 answers

Why should I not use a message bus instead of a Loaders and Services?

In typical Android project where we need to pull data from somewhere (REST, SQL, cache, etc) into the UI in a clean way we commonly use a Loader, Service or (possibly, yuk) an AsyncTask, but I find all these approaches unsatisfactory for several…
20
votes
3 answers

Cursor window could not be created from binder

1 Cursor cursor = contentResolver.query(MY_URI, new String[] { "first" }, null, null, null); 2 if (cursor != null) { 3 if (cursor.moveToFirst()) { 4 first = cursor.getString(cursor.getColumnIndex("first")); 5 cursor.close(); 6 } 7…
villager
  • 5,041
  • 11
  • 45
  • 101
16
votes
4 answers

Android MVP: safe use Context in Presenter

In my app I work with ContentProvider and use LoaderManager.LoaderCallbacks. Fragment (View) public class ArticleCatalogFragment extends BaseFragment implements ArticleCatalogPresenter.View, …
Alexandr
  • 1,871
  • 3
  • 30
  • 47
15
votes
5 answers

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

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…
qkx
  • 2,061
  • 4
  • 22
  • 44
15
votes
2 answers

CursorTreeAdapter with search implementation

I'm making an application for android and I'm using CursorTreeAdapter as ExpandableListView. I want to use a search box for displaying the filtered ExpandableListView items. Like this: Here's the code what I've written so…
15
votes
3 answers

Attempt to re-open an already-closed object: java.lang.IllegalStateException:?

I know this question has asked many times in SO,but i couldn't figure out my exact problem. I am using the following code to get the data from the database(Table1) and update another Table2 based on retrieval value. Its working fine in some android…
vinothp
  • 9,364
  • 17
  • 57
  • 102
14
votes
2 answers

Intent.ACTION_PICK returns empty cursor for some contacts

I have an app in which one aspect is for a user to select a contact and send a text to that contact thru the app. The app only works with some contacts and fails on others. More precisely: for the contacts that I entered into my contact book by…
Pouton Gerald
  • 1,585
  • 21
  • 30
1
2 3
58 59