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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:25:09+00:00 2026-05-26T21:25:09+00:00

I have been trying to work out the bug on this but can’t seem

  • 0

I have been trying to work out the bug on this but can’t seem to find what I’m looking for search Google for the past few days, i have hit and missed on stuff that is leaning towards what i want to do but haven’t ran across anything that is what i am trying to do.

To start off, I built my SQLite DB along with “TheNewBoston Android Tuts” everything works fine, now that I am trying to change the view database around it errors out or crashes the app at start up. I am wanting to display certain columns in a row from the DB with the Cursor using the for loop and to dynamically load the TableView with the data:

DbEntry[ data | data| Displayed | data | Display | Display | data ]

I can do this if i have a TextView off on its own but with it in a TableLayout>TableRow i think that’s where the problem is but not sure… would like to be able to load the table rows from the class its self instead of setting the text views if possible. I hope i gave enough info on what i am trying to do, if anyone can point me to a really good tutorial or give some light on this, it wold be greatly appreciated.

XML:

 <TableLayout
    android:id="@+id/view_Table"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="5" >
 <TableRow   
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4" >
        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1" >
            <TextView
                android:id="@+id/view_DbCol3"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="DB Col 3 Displayed Data" />
        </TableRow>

with xml i hope i am doing the table right that its similar to hmtl kind of things by putting table rows in side one another

SQLview Class

setContentView(R.layout.sqlview);
    TextView tv = (TextView) findViewById(R.id.view_DbCol3);
    try {
        DBload info = new DBload(this);
        info.open();
        String data = info.getData();
        info.close();
        tv.setText(data);
    } catch (Exception e) {
        // Error Message Dialog
        String error = e.getLocalizedMessage();
        Dialog d = new Dialog(this);
        d.setTitle("DB ERROR");
        TextView tv1 = new TextView(this);
        tv1.setText(error);
        d.setContentView(tv1);
        d.show();
    }

DbHelper Class: getData Method

public String getData() {

    String[] cols = new String[] {KEY_PLACE}; 
                 // I have also tried with all my KEY variables

    // reads info from DB columns
    Cursor c = ourDB.query(KEY_TABLE, cols, null, null, null, null, null);
    String result = "";

    int Ione = c.getColumnIndex(KEY_PLACE);

    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
        result = result 
        + c.getString(Ione) 
        + "\n";
    }
    return result;
}

the error i am getting is

11-17 00:13:09.993: E/CursorWindow(590): Bad request for field slot 0,-1. numRows = 2, numColumns = 1

like i said i hope i have given enough information for little help if possible, thanks alot

  • 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-26T21:25:09+00:00Added an answer on May 26, 2026 at 9:25 pm

    This link will help you alot.

    anywayz try this in you code

    if(c.getCount()>0) {
        int index=0;
        while(c.moveToNext()){
    
        result = result  
                + c.getString(index)  
                + "\n"; `enter code here`
        index++;
        }
    }
    

    Hope this helps..

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

Sidebar

Related Questions

Okay I been trying to work this out but unable too. I have a
Hey, have been trying to work this out for last day or so but
I have been pulling my hair out trying to make this work. I have
I've been trying to work with the Google Calendar JSON API, but have been
I've been trying to work out this particular problem and though I can easily
I have been trying to work this out for a while and I just
Hi I have been trying to work out the best way to do this
I have been trying to use a formula that is used to work out
I have been trying to make it work with either fwrite or fputcsv but
I have been trying to get this to work correctly and I think I

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.