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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:53:41+00:00 2026-06-11T13:53:41+00:00

This is my code for reading the data from my database. Here I’m just

  • 0

This is my code for reading the data from my database. Here I’m just receiving the values and printing them using “Toast” class.

public void onClickLogin(View btnLogin)
{
    String email,password;
    String[] cols = new String[] {DataBase_Server.EMAIL, DataBase_Server.PASS};
    EditText edtPassword = (EditText) findViewById(R.id.edtPassword);
    EditText edtLoginId = (EditText) findViewById(R.id.btnLogin);
    DataBase_Server database=new DataBase_Server(login.this);
    SQLiteDatabase db=database.getReadableDatabase();
    Cursor c=db.query(DataBase_Server.TABLE, null, null, null, null, null, null);
    //startManagingCursor(c);
    c.moveToFirst();
    email=c.getString(c.getColumnIndex(DataBase_Server.EMAIL));
    password=c.getString(c.getColumnIndex(DataBase_Server.PASS));
    Toast.makeText(this,email+" hello "+password, Toast.LENGTH_SHORT).show();
}

There are no syntax errors in the code but when I’m running my app and click on my login button I get a force close dialog box which ultimately quits my app and in the “logcat” I see some exception like “Unable to open stack file ……access denied” etc. etc.

logcat:

09-20 01:28:55.524: E/AndroidRuntime(378): java.lang.IllegalStateException: Could not execute method of the activity
09-20 01:28:55.524: E/AndroidRuntime(378):  at android.view.View$1.onClick(View.java:2031)
09-20 01:28:55.524: E/AndroidRuntime(378):  at android.view.View.performClick(View.java:2364)
09-20 01:28:55.564: E/dalvikvm(378): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
09-20 01:45:58.265: E/AndroidRuntime(408): Uncaught handler: thread main exiting due to uncaught exception
09-20 01:45:58.295: E/AndroidRuntime(408): java.lang.IllegalStateException: Could not execute method of the activity
09-20 01:45:58.295: E/AndroidRuntime(408):  at android.view.View$1.onClick(View.java:2031)
09-20 01:45:58.295: E/AndroidRuntime(408):  at android.view.View.performClick(View.java:2364)
09-20 01:45:58.295: E/AndroidRuntime(408):  at android.view.View.onTouchEvent(View.java:4179)
09-20 01:45:58.295: E/AndroidRuntime(408):  at android.widget.TextView.onTouchEvent(TextView.java:6541)
09-20 01:45:58.295: E/AndroidRuntime(408):  at android.view.View.dispatchTouchEvent(View.java:3709)
09-20 01:45:58.295: E/AndroidRuntime(408):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  09-20 01:45:58.295: E/AndroidRuntime(408):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    09-20 01:45:58.295: E/AndroidRuntime(408):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
     09-20 01:45:58.295: E/AndroidRuntime(408):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
      09-20 01:45:58.295: E/AndroidRuntime(408):    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
    09-20 01:45:58.295: E/AndroidRuntime(408):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
     09-20 01:45:58.295: E/AndroidRuntime(408):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
      09-20 01:45:58.295: E/AndroidRuntime(408):    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
    09-20 01:45:58.295: E/AndroidRuntime(408):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
     09-20 01:45:58.295: E/AndroidRuntime(408):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-20 01:45:58.295: E/AndroidRuntime(408):  at android.os.Looper.loop(Looper.java:123)
    09-20 01:45:58.295: E/AndroidRuntime(408):  at android.app.ActivityThread.main(ActivityThread.java:4363)
   09-20 01:45:58.295: E/AndroidRuntime(408):   at java.lang.reflect.Method.invokeNative(Native Method)
    09-20 01:45:58.295: E/AndroidRuntime(408):  at java.lang.reflect.Method.invoke(Method.java:521)
  09-20 01:45:58.295: E/AndroidRuntime(408):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  09-20 01:45:58.295: E/AndroidRuntime(408):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
   09-20 01:45:58.295: E/AndroidRuntime(408):   at  dalvik.system.NativeStart.main(Native Method)
     09-20 01:45:58.295: E/AndroidRuntime(408): Caused by: java.lang.reflect.InvocationTargetException
  09-20 01:45:58.295: E/AndroidRuntime(408):    at com.example.curbrain.login.onClickLogin(login.java:36)
   09-20 01:45:58.295: E/AndroidRuntime(408):   at java.lang.reflect.Method.invokeNative(Native Method)
  09-20 01:45:58.295: E/AndroidRuntime(408):    at java.lang.reflect.Method.invoke(Method.java:521)
   09-20 01:45:58.295: E/AndroidRuntime(408):   at android.view.View$1.onClick(View.java:2026)
     09-20 01:45:58.295: E/AndroidRuntime(408):     ... 21 more
   09-20 01:45:58.295: E/AndroidRuntime(408): Caused by: java.lang.ClassCastException: android.widget.Button
   09-20 01:45:58.295: E/AndroidRuntime(408):   ... 25 more
    09-20 01:45:58.325: E/dalvikvm(408): Unable to open stack trace file '/data/anr/traces.txt': Permission denied

XML CODE :

android:onClick="onClickLogin"
  • 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-11T13:53:42+00:00Added an answer on June 11, 2026 at 1:53 pm

    Your trying to reference your XML login EditText but you’ve actually used the ID of an Button:

     EditText edtLoginId = (EditText) findViewById(R.id.btnLogin); 
    

    Therefore you cannot cast the view returned (a Button) to an EditText

    That id is for a button: R.id.btnLogin check your XML for the correct ID.

    The line explaining it in your LogCat is:

     09-20 01:45:58.295: E/AndroidRuntime(408): Caused by: java.lang.ClassCastException: android.widget.Button
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code to read data from Oracle Database. That data stored
I have my code that is reading values from a database and then putting
i am reading an excel file using this code i found over the net:
Note: This code actually codes from a tutorial book I'm reading at the moment,
I am using C to open a file for reading. I have this code
I'm reading code from GraphServer . And there is this function that has weird
If you have to retrieve data from a database and bring this dataset to
I need to export big amount of data from database. Here is classes that
I am using the following script to import data into my mysql database from
I'm reading this code sample : And since I don't know C#, I decided

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.