Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8300073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:24:58+00:00 2026-06-08T16:24:58+00:00

I am new to Android programming and have a basic question. I have created

  • 0

I am new to Android programming and have a basic question.

I have created a ListActivity where each row in its ListView has a TextView and a RatingBar. I am able to display values in the TextView and RatingBar by reading them from a pre-populated database; I am doing this via a custom CursorAdapter and it’s bindView() method, i.e.

public class MyCursorAdapter extends CursorAdapter {
    ...

    public void bindView(View view, Context context, final Cursor cursor) {
        TextView name = (TextView)view.findViewById(R.id.name);
        name.setText(cursor.getString(cursor.getColumnIndex(MyDbAdapter.KEY_NAME)));
        RatingBar rating = (RatingBar)view.findViewById(R.id.life_bar_rating);
        rating.setRating(cursor.getFloat(cursor.getColumnIndex(MyDbAdapter.KEY_RATING_VALUE)));
    }

    ...
}

Now, my problem is that in my ListActivity I want the user to be able to click a “Save” button so that all changes are saved to the database in one go?. How would I iterate through the adapter to get the row ID and rating values so they can be saved (or is there another better way of doing this?).

The reason why I want to do a save in one go is because I thought it would be bad practice to update the database every time the user makes a change to a single rating (even though this is easier) as this causes more wear and tear on flash memory. I may be wrong about this, but I thought that there are a limited number of reads and writes with flash memory.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:25:00+00:00Added an answer on June 8, 2026 at 4:25 pm

    Remember the Adapter’s backing array? The one you used to initialize it? save that 😉

    or if that doesn’t work…

    for(int i = 0; i < listView.getAdapter().getCount(); i++)
        SaveThing(listView.getAdapter().getItem(i));
    

    if you need SQLite examples of saving… tomorrow.

    edit for same of keeping comments clean:

    as far as that object thing goes – you’re free to cast it to anything that’s in the listview. the data type, not view type.

    so for example, an arrayAdapter that works with strings still returns Objects. but you will most certainly cast them to Strings because you know that’s what you put in. it’s awkward but thats how it is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really new in Android programming, so I have a simple question getting a
I'm new to android programming and i have a question I'm developing an alarm
I'm new to Android programming. I have a UI with some TextView and Button
I'm new to android and programming in general so go easy! I have created
So I am fairly new to android programming. I have a database and I
I'm new to Android & Java programming but have been programming in .NET for
I am new to Android and Java programming. I have a class which implements
I'm very new to Android programming, so this is probably something pretty basic. I
Alright, so I'm new to Android programming, so far my experience has been quite
I am new to Eclipse and Android programming in general but I have been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.