0

throwing a fatal error while going to display message using TextView.. iam using this program I sets some loger also.It is run good upto logger="lastmark".

        private void displayText(String message){
        logger.info("inside display message");
        TextView textView = (TextView)findViewById(R.id.name_1);
        logger.info("last mark");
        textView.setText(message);

    }
    public void callStatus(){

        logger.info("inside 3 rd step");
        dataBase = DataBaseManager.instance();

        logger.info("inside 4 rd step");
        //to get data from database we need a cursor.
        //after we perform a select query all the data from database specific for the query, will be in the cursor
        // "*" means "all" in translation the query means "SELECT ALL FROM NAME TABLE"

        cursor = dataBase.select("SELECT * FROM " + TABLE_NAME);
        logger.info("inside 4b rd step");
        String s ="";
        logger.info("inside 5 rd step");

        //the cursor iterates the column "name"
        while (cursor.moveToNext()){
            do{


            //in this string we get the record for each row from the column "name"
            logger.info("inside 6 rd step");
            String s1 = cursor.getString(cursor.getColumnIndex(COLUMN_NAME1));
            String s2 = cursor.getString(cursor.getColumnIndex(COLUMN_NAME2));
            s = s1+s2;
            }while  (cursor.moveToNext());
            logger.info("inside 7 rd step");
            //in this textView will be added, updated or deleted the string
            // "\n" means "new line"
        }

        //here we close the cursor because we do not longer need it
        cursor.close();
        logger.info("inside 8 rd step");
        displayText(s);
    }


}

....throwing a fatal error while going to display message using TextView.. iam using this program I sets some looger also.It is run good upto logger="lastmark".

1
  • 1
    This is probably because your textView is null when you call textView.setText(message); Where are you inflating your layout? Post your onCreate method. Commented Aug 19, 2013 at 1:54

2 Answers 2

1

Try this:

After creating the cursor

if (cursor.moveToFirst())
{
    do
    {
       // get column1 and column2 
       ....
    } while (cursor.moveToNext())
}

And make sure you close the cursor after all the cursor operations.

Sign up to request clarification or add additional context in comments.

Comments

0

I know ,before while (cursor.moveToNext()){……} ,you should move the cursor to first
cursor.moveToFirst() must be performed firstly!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.