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 4323938
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:03:58+00:00 2026-05-21T09:03:58+00:00

I am query my sqlite data base for my Android app. I then use

  • 0

I am query my sqlite data base for my Android app.

I then use a simple cursor adapter to bind the data to a list view.

there are two doubles being called from the database and on the list view the only show up as 6 digits long.

Example: 43.6234 and -116.203

in the database (I dumped it) these numbers have a lot more digits.

What went wrong?
Here is my row XML for the list view

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
        <TextView android:text="@string/ssid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/row_db_ssid" android:textSize="16dip"></TextView>
        <TextView android:layout_height="wrap_content" android:layout_below="@+id/row_db_bssid" android:textSize="12dip" android:text="@string/lati" android:layout_width="wrap_content" android:id="@+id/row_db_latitude"></TextView>
        <TextView android:text="@string/bssid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/row_db_bssid" android:layout_below="@+id/row_db_ssid" android:textSize="14dip"></TextView>
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="@string/rssi" android:textSize="16dip" android:id="@+id/row_db_rssi"></TextView>
        <TextView android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@+id/row_db_bssid" android:textSize="12dip" android:text="@string/longi" android:layout_width="wrap_content" android:id="@+id/row_db_longitude"></TextView>
    </RelativeLayout>
  • 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-05-21T09:03:59+00:00Added an answer on May 21, 2026 at 9:03 am

    After looking here: krysanify.wordpress.com/2010/11/24/… I have found a flaw in the SimpleCursorAdapter that just assumes the fields will be strings loosing the precision wanted

    I extended the SimpleCursorAdapter to use Double on the rows I wanted here is the class.

    public class WithLongAdapter extends SimpleCursorAdapter {
        private int[] mFrom;
        private int[] mTo;
    /**
     * SimpleCursorAdapter that also checks for Double values based on rows so they will not be truncated
     * @param context pass this
     * @param layout the row file
     * @param c the Cursors
     * @param from collums on cursor
     * @param to rows on list
     */
        public WithLongAdapter(Context context, int layout, Cursor c,
                String[] from, int[] to) {
            super(context, layout, c, from, to);
            mTo = to; //have to make my own to and from because they are protected in SimpleCursorAdapter
            if (c != null) {
                int i;
                int count = from.length;
                if (mFrom == null || mFrom.length != count) {
                    mFrom = new int[count];
                }
                for (i = 0; i < count; i++) {
                    mFrom[i] = c.getColumnIndexOrThrow(from[i]);
                }
            } else {
                mFrom = null;
            }
        }
    
        @Override
        public void bindView(View view, Context context, Cursor cursor) {
            final ViewBinder binder = getViewBinder();
            final int count = mTo.length;
            final int[] from = mFrom;
            final int[] to = mTo;
    
            for (int i = 0; i < count; i++) {
                final View v = view.findViewById(to[i]);
                if (v != null) {
                    boolean bound = false;
                    if (binder != null) {
                        bound = binder.setViewValue(v, cursor, from[i]);
                    }
    
                    if (!bound) {
                        String text = cursor.getString(from[i]);
                        if (text == null) {
                            text = "";
                        } else if (R.id.row_db_latitude == v.getId()) { //added rows, if they are the ones I want get value of doulbe
                            text = String.valueOf(cursor.getDouble(from[i]));
                        }
                        else if (R.id.row_db_longitude == v.getId()) { //added row
                            text = String.valueOf(cursor.getDouble(from[i]));
                        }
                        if (v instanceof TextView) {
                            setViewText((TextView) v, text);
                        } else if (v instanceof ImageView) {
                            setViewImage((ImageView) v, text);
                        } else {
                            throw new IllegalStateException(
                                    v.getClass().getName()
                                            + " is not a "
                                            + " view that can be bounds by this SimpleCursorAdapter");
                        }
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble searching a SQLite database in my Android app. I use
My Android app is crashing with this error: E/AndroidRuntime( 315): Caused by: android.database.sqlite.SQLiteException: bind
Activity: package hi.com; import android.app.Activity; import android.content.ContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import
Is there any way to create a pivot and/or cross-tab query using for SQLite
Here is my code for my db class: package one.two; import java.util.List; import android.app.ListActivity;
on the cursor line this error occurs. Error: Caused by: android.database.sqlite.SQLiteException: near ): syntax
My question is concerned with SQLite database in Android. When I use a statement
I've got an android app using a local sqlite database. private SQLiteDatabase mDb; when
I'm using Sqlite with android to develop and app which can be customizable (for
the Events class package org.examples.events; import android.app.ListActivity; import android.content.ContentValues; import android.widget.SimpleCursorAdapter; import android.database.Cursor; import

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.