How to get the sum of columns in android sqlite?

I’m creating a delivery tip tracker application for android, and using SQLite to store all of the customers’ data. I have almost everything working that I need except for a running total of my tips for the night. My code is as follows:

public View getView(int position, View convertView, ViewGroup parent) {

    if (inflater == null)
        inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null)
        convertView = inflater.inflate(R.layout.contact_entry, null);

    TextView name= (TextView) convertView.findViewById(;
    TextView contact = (TextView) convertView.findViewById(;
    TextView address = (TextView) convertView.findViewById(;
    TextView orderTotal = (TextView) convertView.findViewById(;
    TextView amountReceived = (TextView) convertView.findViewById(;
    TextView tip = (TextView) convertView.findViewById(;
    TextView mileage = (TextView) convertView.findViewById(;
    TextView grandTotal = (TextView) convertView.findViewById(;
    Button delete = (Button) convertView.findViewById(;

    PhoneBook list = contactList.get(position);

    delete.setOnClickListener(new ListItemClickListener(position, list));

    TextView deliveryNumber = (TextView) convertView.findViewById(;
    deliveryNumber.setText("Delivery # " + (position + 1));

    TextView runningTotal = (TextView) convertView.findViewById(;

    return convertView;

When the user clicks the “Save” button in the main window, all of the information for the delivery is saved to the database and displayed in a listview in a separate window. So if I have 3 deliveries for the night, I have 3 listviews stacked on top of each other. I’m trying to create a TextView called “runningTotal” that displays the running total of my tips for the night, each which is stored in a variable called grandTotal. But I can’t figure out how to sum up the grandTotal column to get that information. Any help would be greatly appreciated! It’s for a final project in Mobile App Development. I ask the question on StackOverflow, and pretty much get treated like I’m an idiot. Maybe that’s partially true, but I just have no idea how to do it. I’ve found ways to create a method to get the sum, but no idea where to put that method in my code, or how to save it to a textview.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.