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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:44:27+00:00 2026-06-17T13:44:27+00:00

I couldn’t find a suitable title for my question. Here is the problem… After

  • 0

I couldn’t find a suitable title for my question. Here is the problem… After syso‘ing the statement in getData(), it should print the values in the cursor, cMainTable, using the statement in displayDataForMainTable(). But, it doesn’t. There are no exceptions, and errors. I have also kept the output that i get in the LogCat. Can someone help me with, why there is no output after the first print.

try {
    pm = new PortfolioManager(this);
    cMainTable = pm.getData("mainTable");
    if (cMainTable.equals(null)) {
        System.out.println("Null is returned");
    }
    displayDataForMainTable(cMainTable);
}
catch (Exception e) {
    System.out.println("problem at Oncreate Method");
}

getData() method:

public Cursor getData(String string) {
    System.out.println("Getting Data for Table " + string);
    c = sqlDB.rawQuery("select * from " + string, null);      
    return c;
}

displayDataForMainTable() method:

private void displayDataForMainTable(Cursor c2) {
    try {
        if (c2 != null) {
            if (c2.getCount() > 0) {
                c2.moveToFirst();
                do {
                    String SNo = c2.getString(c2.getColumnIndex("scriptnumber"));
                    String SName = c2.getString(c2.getColumnIndex("scriptname"));
                    int quant = Integer.parseInt(c2.getString(c2.getColumnIndex("totalquantity")));
                    double avg = Double.parseDouble(c2.getString(c2.getColumnIndex("averageprice")));
                    double cur = Double.parseDouble(c2.getString(c2.getColumnIndex("currentprice")));
                    double log = Double.parseDouble(c2.getString(c2.getColumnIndex("lossorgain")));
                    System.out.println("Inserted Values are ::: " + SNo
                            + " " + SName + " " + String.valueOf(quant)
                            + " " + String.valueOf(avg) + " "
                            + String.valueOf(cur) + " "
                            + String.valueOf(log));
                } while (c2.moveToNext());
            }
        } 
        else {
            System.out.println("Cursor c2 is Empty");
        }
    } catch (Exception e) {
        System.out.println("Exception in displayDataForMainTable");
    }
}

output

01-18 11:02:27.523: D/dalvikvm(468): GC_EXTERNAL_ALLOC freed 47K, 53% free 2567K/5379K, external 2090K/2137K, paused 45ms
01-18 11:02:33.983: I/System.out(468): Getting Data for Table mainTable
01-18 11:02:36.584: W/KeyCharacterMap(468): No keyboard for id 0
01-18 11:02:36.584: W/KeyCharacterMap(468): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

Edit 1 :::
I have modified the getData() as suggested by Nasser, but the output remains the same..

public Cursor getData(String string) {
    System.out.println("Getting Data for Table "+string);
    String table = string;
    sqlDB = getReadableDatabase();
    c = sqlDB.query(table, null, null, null, null, null, null);
    //c = sqlDB.rawQuery("select * from "+string, null);        
    return c;
}

As I read, passing null to the columns(2nd argument) will return all the rows. If this is correct, then the result is the same.

  • 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-17T13:44:29+00:00Added an answer on June 17, 2026 at 1:44 pm

    It seems that Eclipse has shown mercy on me and is displaying the output. Fought for over 4 hours changing code, surfing, finally ended up with no changes in code.

    No matter how smart you are as a coder, IDEs always make you feel a novice.

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

Sidebar

Related Questions

I couldn't find a suitable title for this. I'm going to express my query
Couldn't find a better way to phrase this question. Here's the deal: I have
I couldn't find any useful information on Microsoft's site, so here is the question:
I couldn't find a straight answer to my question and need to know it
Couldn't figure out how to word the question accurately, so here's an example: Given
Couldn't think of a more appropriate question title, but I'm looking for some advice
I couldn't find this question asked, so I gotta ask: how closely does Android
Couldn't find an answer to this question. It must be obvious, but still. I
I couldn't find the answer to this question in SO. I'll try to explain.
I couldn't seem to find a similar question to this. I am currently looking

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.