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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:44:20+00:00 2026-06-01T15:44:20+00:00

java.lang.IllegalStateException: Could not execute method of the activity . I am new to Android.

  • 0

java.lang.IllegalStateException: Could not execute method of the activity .

I am new to Android. want to display stored data from database.
This is my Compview class which is getting error.

  @Override
     public void onCreate(Bundle savedInstanceState) 
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.compview);


        DB = (new DBHelper(this)).getWritableDatabase();
        // searchText = (EditText) findViewById (R.id.searchText);

         eun = (TextView)findViewById(R.id.textV);
   Bundle bundle = getIntent().getExtras();

   String UName = bundle.getString("UserName");

   eun.setText(UName);



     }

  public void search(View view)
  {DB.isReadOnly();
   cursor = DB.rawQuery("SELECT _id, Cname, Cpost, Ccriteria, Cemail,Ccontact,Ccutoff FROM Comp WHERE Cusername LIKE ?", 
     new String[] {"%" + eun.getText().toString() + "%"});
   adapter = new SimpleCursorAdapter(
     this,
     R.layout.cmpinfo,
     cursor,
     new String[] {" Cname", "Cpost", "Ccriteria", "Cemail","Ccontact","Ccutoff"},
     new int[] {R.id.cname, R.id.cpost, R.id.ccriteria , R.id.cemail, R.id.ccontact, R.id.ccutoff});


   setListAdapter(adapter);
  }

  @Override
  public void onBackPressed() 
  {
   super.onBackPressed();
   Intent i = new Intent(CompView.this, LoginActivity.class);
   startActivity(i);
  }
  }

LOGCAT

04-09 01:32:54.322: W/dalvikvm(4302): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-09 01:32:54.342: E/AndroidRuntime(4302): FATAL EXCEPTION: main
04-09 01:32:54.342: E/AndroidRuntime(4302): java.lang.IllegalStateException: Could not execute method of the activity
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.view.View$1.onClick(View.java:2072)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.view.View.performClick(View.java:2408)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.view.View$PerformClick.run(View.java:8816)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.os.Handler.handleCallback(Handler.java:587)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.os.Looper.loop(Looper.java:123)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at java.lang.reflect.Method.invokeNative(Native Method)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at java.lang.reflect.Method.invoke(Method.java:521)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at dalvik.system.NativeStart.main(Native Method)
04-09 01:32:54.342: E/AndroidRuntime(4302): Caused by: java.lang.reflect.InvocationTargetException
04-09 01:32:54.342: E/AndroidRuntime(4302):     at com.google.data.CompView.search(CompView.java:68)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at java.lang.reflect.Method.invokeNative(Native Method)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at java.lang.reflect.Method.invoke(Method.java:521)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.view.View$1.onClick(View.java:2067)
04-09 01:32:54.342: E/AndroidRuntime(4302):     ... 11 more
04-09 01:32:54.342: E/AndroidRuntime(4302): Caused by: java.lang.IllegalArgumentException: column ' Cname' does not exist
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:312)
04-09 01:32:54.342: E/AndroidRuntime(4302):     at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:87)
04-09 01:32:54.342: E/AndroidRuntime(4302):     ... 15 more

DBHelper class

  public class DBHelper extends SQLiteOpenHelper 


{
 private SQLiteDatabase db;
 public static final String KEY_ROWID = "_id";
 public static final String KEY_ROWID1 = "_id";
    public static final String KEY_FNAME = "firstname";
    public static final String KEY_LNAME = "lastname";
    public static final String KEY_GENDER = "gender";
    public static final String KEY_USER = "username";
    public static final String KEY_EMAIL = "email";
    public static final String KEY_CNAME="Cname"; 
    public static final String KEY_CPOST="Cpost"; 
    public static final String KEY_CCRITERIA="Ccriteria"; 
    public static final String KEY_CUSER="Cusername"; 
    public static final String KEY_CEMAIL="Cemail"; 
    public static final String KEY_CCONTACT="Ccontact"; 
    public static final String KEY_CCUTOFF="Ccutoff"; 


 DBHelper DB = null;
 private static final String DATABASE_NAME = "Sam1.db";
 private static final int DATABASE_VERSION = 2;
    public static final String DATABASE_TABLE_NAME = "JobSeeker";
    public static final String Company_Table = "Comp";
    private static final String DATABASE_TABLE_CREATE =
            "CREATE TABLE " + DATABASE_TABLE_NAME + "(" +
            "_id INTEGER PRIMARY KEY AUTOINCREMENT,"+
            "firstname TEXT NOT NULL, lastname TEXT NOT NULL, gender TEXT NOT NULL, username TEXT NOT NULL, password TEXT NOT NULL, email TEXT NOT NULL);";
private static final String DATABASE_TABLE_CREATE2=
" create table " + Company_Table +
" (_id integer primary key autoincrement," +
" Cname TEXT NOT NULL, Cpost TEXT NOT NULL,Ccriteria TEXT NOT NULL,Cusername TEXT NOT NULL, Cpassword TEXT NOT NULL, Cemail TEXT NOT NULL,Ccontact TEXT NOT NULL,Ccutoff TEXT NOT NULL);" ;


    public DBHelper(Context context) {

  super(context, DATABASE_NAME, null, DATABASE_VERSION);
  System.out.println("In constructor");
}




@Override
public void onCreate(SQLiteDatabase db) {

 try{

  db.execSQL(DATABASE_TABLE_CREATE);
  db.execSQL(DATABASE_TABLE_CREATE2);



 }catch(Exception e){
  e.printStackTrace();
 }
}






@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
 // TODO Auto-generated method stub

}




public Cursor rawQuery(String string, String[] strings) {
 // TODO Auto-generated method stub
 return null;
}




public void open() {

 getWritableDatabase(); 
}


public Cursor getDetails(String text) throws SQLException 
{

    Cursor mCursor =
            db.query(true, DATABASE_TABLE_NAME, 
              new String[]{KEY_ROWID, KEY_FNAME, KEY_LNAME, KEY_GENDER, KEY_USER, KEY_EMAIL}, 
              KEY_USER + "=" + text, 
              null, null, null, null, null);
    if (mCursor != null) 
    {
        mCursor.moveToFirst();
    }
    return mCursor;


}

public Cursor getCompDetails(String text) throws SQLException 
{

    Cursor mCursor =
            db.query(true, Company_Table, 
              new String[]{KEY_ROWID1, KEY_CNAME, KEY_CPOST, KEY_CCRITERIA, KEY_CUSER, KEY_EMAIL,KEY_CCONTACT,KEY_CCUTOFF}, 
              KEY_CUSER + "=" + text, 
              null, null, null, null, null);
    if (mCursor != null) 
    {
        mCursor.moveToFirst();
    }
    return mCursor;


}


}

This my welcome1 class which is working fine and able to retrieve all the data from database but when am using same method for my compview class to access data its not working.!!

public class Welcome1 extends ListActivity
{


 protected TextView eun;
 protected SQLiteDatabase DB;
 protected Cursor cursor;
 protected ListAdapter adapter;
 protected TextView mUname;
 protected TextView mFname;
 protected TextView mLname;
 protected TextView mEmail;


  @Override
     public void onCreate(Bundle savedInstanceState) 
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.welcome1);


        DB = (new DBHelper(this)).getWritableDatabase();
        // searchText = (EditText) findViewById (R.id.searchText);

         eun = (TextView)findViewById(R.id.textV);
   Bundle bundle = getIntent().getExtras();

   String UName = bundle.getString("UserName");

   eun.setText(UName);



     }

  public void search(View view)
  {
   cursor = DB.rawQuery("SELECT _id, firstname, lastname, gender, username, email FROM JobSeeker WHERE username LIKE ?", 
     new String[] {"%" + eun.getText().toString() + "%"});
   adapter = new SimpleCursorAdapter(
     this,
     R.layout.dtl,
     cursor,
     new String[] {"firstname", "lastname", "gender","username", "email"},
     new int[] {R.id.sfname, R.id.slname, R.id.sgender , R.id.suname, R.id.semail});


   setListAdapter(adapter);
  }

  @Override
  public void onBackPressed() 
  {
   super.onBackPressed();
   Intent i = new Intent(Welcome1.this, LoginActivity.class);
   startActivity(i);
  }
  }
  • 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-01T15:44:21+00:00Added an answer on June 1, 2026 at 3:44 pm

    The problem is with the from parameter when creating adapter

    adapter = new SimpleCursorAdapter(
        this,
        R.layout.cmpinfo,
        cursor,
        new String[] {" Cname", "Cpost", "Ccriteria", "Cemail","Ccontact","Ccutoff"},
        new int[] {R.id.cname, R.id.cpost, R.id.ccriteria , R.id.cemail, R.id.ccontact, R.id.ccutoff});
    

    Look at where you create the String[] array…

    new String[] {" Cname", "Cpost", "Ccriteria", "Cemail","Ccontact","Ccutoff"}
    

    …you have a space before Cname.

    The logact output shows this…

    column ' Cname' does not exist
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm getting this error 11-15 16:55:40.617: E/AndroidRuntime(316): java.lang.IllegalStateException: Could not find a method
java.lang.IllegalStateException: System services not available to Activities before onCreate() at android.app.Activity.getSystemService(Activity.java:3536) at android.accounts.AccountManager.get(AccountManager.java:261) at
Description for java.lang.IllegalStateException from the Java docs: Signals that a method has been invoked
This method throws java.lang.IllegalStateException: Cannot forward after response has been committed and I am
During navigation of the java.lang.reflect.Method class I came across the method isBridge . Its
If you decompile the java.lang.Class class in java from the rt.jar library you will
Why is java.lang.Thread in the Google App Engine whitelist when it is not supported?
This the exception: java.lang.IllegalStateException: this kind of handler cannot be attached to multiple components;
I'm trying to invalidate a session. When I call: session.invalidate() it throws java.lang.IllegalStateException: getLastAccessedTime:
import java.lang.Math; public class NewtonIteration { public static void main(String[] args) { System.out.print(rootNofX(2,9)); }

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.