FAQ Database Discussion Community


Using String as _id in CursorAdapter

android,sqlite3,android-cursoradapter
It's a requirement of using a CursorAdapter that: The Cursor must include a column named "_id" or this class will not work. It's clear from the getItemId() signature, and the CursorAdapter source, that this column is expected to be an integral type: /** * @see android.widget.ListAdapter#getItemId(int) */ public long getItemId(int...

How to implement an endless CursorAdapter?

android,android-listview,cursor,android-cursoradapter,android-cursor
At our company we are developing an app that displays a timeline. We are willing to let the user scroll it (almost) indefinitely. Now there are 2 facts to consider: loading a large cursor can have a bad impact on performances (true especially for old devices) cursors seem to have...

Implementing own Android CursorAdapter for search suggestions - unknown exceptions

java,android,sqlite,searchview,android-cursoradapter
I have implemented my own cursor adapter to manually handle suggestions, so that I can get rid of the overkill method that android docs proposes. Basically what I do is setOnQueryTextListener to the actionbar searchview after it's been inflated. Everytime the user inputs a new search text, I query a...

How to create a list view contains data from sqlite in android

android,sqlite,android-cursoradapter
I am trying to display data from an SQLite database in a ListView. I use a CursorAdapter to directly plug the Cursor into the ListView but for some reason I am always getting an exception. This is my modified DBadapter activity: public static final String ID="_id"; public Cursor feching_Data(){ String[]...

Android: problems with CursorAdapter

android,sqlite,listview,android-cursoradapter,populate
first of all thank you all for your answers and sorry for the bad English used, have a controller class to populate a listview and an adapter class that extends CursorAdapter, my problem is that when I setAdapter, my class adapter is not running the Newview method BindView certainly not...

Inflating LinearLayout for CursorAdapter

android,android-cursoradapter,android-inflate
I'm trying to create a view from CursorAdapter. However, when I inflate a layout, I'd like to inflate LinearLayout instead of the whole .xml layout. For example, <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/opera_house_background"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"...

ListView won't update even if I call notifyChange(uri, null); though content provider

android,android-contentprovider,android-cursoradapter
I'm having trouble trying to get my ListView to refresh when new data gets added to the content provider. Reading similar posts on this issue, I made sure to use getContext().getContentResolver().notifyChange(uri, null); on my insert method and c.setNotificationUri(getContext().getContentResolver(), uri); on my query method (talking about the content provider class). I...

Contantly updating textview in a custom cursor adapter

android,simplecursoradapter,android-cursoradapter,timeline
I have a TimelineViewActivity class, contains a listView TimelineFeedsCursorAdapter class, extends the CursorAdapter Here, in this adapter class I am fetching the rows from SQLite db and populating the list. Now in each list item there is a time specifying when was the timeline feed created i.e. 2 hours ago...

Android database custom listview open to multiple activities [closed]

android,listview,android-cursoradapter
I found this app that uses a database with multiple tables. This here is a listview that saves incomes and expenses but they are in different activities. Does anyone knows how can I make this kind of listview?...

Android ListFragment with custom CursorAdapter not showing data

android,android-listview,android-listfragment,android-cursoradapter
So basically I have a ListFragment setup like this public class ObavijestiFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { private View mApiError; private ObavijestiAdapter mAdapter; private static String TAG="ObavijestiFragment"; public static ObavijestiFragment newInstance() { return new ObavijestiFragment(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_obavijesti,...

Displaying items in listView from sqlite database (Android)

android,sqlite,listview,android-cursoradapter
I am trying to populate a list view on android. I've written the code and it runs without errors, however it crashes when i try to run it. Below is the Populate list view method: private void populateListView() { Cursor cursor = db.getAllRows(); String[] fromFieldNames = new String[]{MySQLiteHelper.KEY_TITLE, MySQLiteHelper.KEY_AUTHOR}; int[]...

How to cast the cursor from a fragment to a new activity?

android,android-fragments,android-fragmentactivity,android-cursoradapter,android-cursor
I have a working ListView, in a fragment and when the ListItem is clicked I want to link the data to a new Activity. I am getting an error that my db object cannot be cast to the db Cursor import android.app.ActionBar; import android.app.FragmentTransaction; import android.content.Intent; import android.database.Cursor; import android.os.Bundle;...

Android Error implementing CursorAdapter - Column _id

android,android-sqlite,android-cursoradapter
recently that I use sqlite in android and I have a problem not solved. I found a tutorial that explains how to run a database and works perfectly. I'm happy to have found. Now I want to implement a CursorAdapter to customize the listview containing the data of the DB...

How can I reference a cursor

android,simplecursoradapter,android-cursoradapter,android-cursorloader
I wish to use a CursorLoader in my application but I don't want to use the returned cursor with a SimpleCursorAdapter. I just want to get a reference of the cursor returned from onLoadFinished() Here is some code public class MainActivity extends Activity implements LoaderManager.LoaderCallbacks<Cursor> { @Override public void onCreate(Bundle...

Crash while scrolling a cursor backed listview

android,android-listview,android-cursoradapter
Like the title says, I have a listview populated with a cursoradapter. I can scroll the list just fine for the first 50 elements let's say, however it crashes if I try to scroll further, and it crashes always at the same point. I include the stack trace, it hasn't...

ArrayList is not working properly in CursorAdapter

java,android,sqlite,arraylist,android-cursoradapter
I am trying to get database from SQLite database and trying to populate the ListView and also adding data in ArrayList<String> . The ListView is populated nicely but problem is ArrayList<String> is not populated nicely. Suppose I have data in database like: A B C D E F G H...

Change row color of a ListView with Cursoradapter and bindView

android,listview,android-listview,android-cursoradapter
I got some trouble, when I click on my Listview I would like to change the color of the selected row, but a several row change color instead of the one I want. If I click on another row i want that the previous clicked row keep his color. There's...