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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:38:25+00:00 2026-06-17T19:38:25+00:00

I have two classes, one called SQLiteExample and it has a switch statement. in

  • 0

I have two classes, one called SQLiteExample and it has a switch statement. in this switch is a button click listener where i want to read the resulting int into a TextView, this does not work. i can read the int into a Toast message and display it with no errors. however when reading it into a textview I don’t know why it gets an error in the logcat when i do this. the TextView is registered correctly.

 public class SQLiteExample extends Activity implements OnClickListener {

 case R.id.bSQLnumberofrows:
        PlayGame ec = new PlayGame(this);
        ec.open();
        int x = ec.fetchPlacesCount();
        ec.close();
        showNumbers.setText(x);  // setText not working
                     // Toast message works perfectly and displays value of "x" on screen
        Toast.makeText(SQLiteExample.this, "value of x " + x , Toast.LENGTH_SHORT).show();
        break;

here is the logcat errors:

01-25 10:52:04.540: E/AndroidRuntime(8449): FATAL EXCEPTION: main
01-25 10:52:04.540: E/AndroidRuntime(8449): android.content.res.Resources$NotFoundException: String resource ID #0x5
01-25 10:52:04.540: E/AndroidRuntime(8449):     at android.content.res.Resources.getText(Resources.java:247)
01-25 10:52:04.540: E/AndroidRuntime(8449):     at android.widget.TextView.setText(TextView.java:3473)
01-25 10:52:04.540: E/AndroidRuntime(8449):     at com.example.dbsample.SQLiteExample.onClick(SQLiteExample.java:127)

the line 127 is where the exception is: showNumbers.setText(x);

and the other class is PlayGame and has a method to get the number of rows in an SQLite database as an int:

 public class PlayGame {

 public int fetchPlacesCount() {
        int count = 0;
        Cursor q = ourDatabase.rawQuery("SELECT COUNT(*) from " + DATABASE_TABLE, null);
        q.moveToFirst();
       count = q.getInt(0);
        return count;
    }
  • 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-17T19:38:26+00:00Added an answer on June 17, 2026 at 7:38 pm

    You are calling the version of setText() which accepts an int parameter which is expected to refer to a string resource in an XML file. You need to convert your int to a String in order to display its value in a TextView. Note that you are doing this implicitly with "value of x " + x when using a Toast. You can explicitly convert an int into a String by calling String.valueOf(x).

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

Sidebar

Related Questions

I have two classes. One is called Employee and the other EmployeeDetails that has
First I want to describe my situation briefly. I have two classes, one MainClass
Possible Duplicate: Object destruction in C++ Suppose we have two classes, one is called
Hi I have two classes, one called Instruction, one called LDI which inherits from
So I have two classes. One is a class called Main. The Main class
I have two classes. One class has a variable Image plane = null; in
I have two classes one called Person the other called Student I have been
Let´s say I have two PHP classes one called gallery and one called image
First, a little background (greatly simplified): I have two classes, one called Entity and
I have defined two classes in javascript as follows. function ParentClass(){ this.one = function(){

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.