You request only one column (passwd). The column index in the cursor
is 0-based, so you should do :

password = c.getString(0);

And you should test the size of your cursor :

 if(c!=null && c.moveToFirst()) {
        password = c.getString(0);
}



On 14 avr, 09:10, amey bura <[email protected]> wrote:
> hi.. i have created login(empname , passwd) table.. I am trying to
> fetch passwd from table for perticular empname by calling a function
> getpwd ()from another activity ..
> I am using following query..
>
> public String getpwd(String uname)  throws SQLException
>
> {
>     Cursor c  = db.rawQuery("select passwd from emp where
> empname='"+uname+"'" ,null);
>           if(c!=null)
>        c.moveToFirst();
>           password = c.getString(4);
>
> }
>
> This code giving an error in logcat as
> java.lang.IllegalStateException: &  initialise cursor properly..
>
> can anyone plz tell me how to remove this errors..?
>
> any  suggetions  are welcome..

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to