Results 1 to 2 of 2

Thread: Android Login

  1. #1
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default Android Login

    Hey Guys,

    I'm working on an android login activity where one must enter just a username to access the main menu. However I'm getting this error in the log when I try to enter my username.

    NOTE :swalsh = username


    SQLiteException no such column swalsh while compiling SELECT DISTINCT USERNAME FROM members where USERNAME equals swalsh

    The table members defiantly exists and the username is defiantly swalsh.


    Here Is my loginactivity

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);
    db = new MyDB(this);
    db.open();
    username = (AutoCompleteTextView)findViewById(R.id.txtUsernam e);
    password = (AutoCompleteTextView)findViewById(R.id.txtPasswor d);
    username.setText(Username);
    password.setText(Password);
    btnLogin = (Button)findViewById(R.id.btnLogin);
    btnLogin.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
    try {
    readfromDB();

    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    });
    }
    public void readfromDB(){
    //save to DB
    db.readlogin(username.getText().toString());
    db.close();
    username.setText("");
    // password.setText("");
    Toast.makeText(Login.this, "Login Successful!!", Toast.LENGTH_SHORT).show();
    Intent i = new Intent(Login.this, MainMenu.class);
    startActivity(i);
    // if(Username == (Constants.USERNAME) && Password == (Constants.PASSWORD)){
    // Toast.makeText(Login.this, "Login Passed!!", Toast.LENGTH_SHORT).show();
    // Intent i = new Intent(Login.this, MainMenu.class);
    // startActivity(i);
    // }
    // else{
    // Toast.makeText(Login.this, "Login Failed!!", Toast.LENGTH_SHORT).show();
    // }

    }

    }


    And this is my Database


    public void readlogin(String username) throws SQLException {

    Cursor mCursor =

    db.query(true, Constants.MEMBERS_TABLE, new String[] {
    Constants.USERNAME}, Constants.USERNAME + "=" + username, null,
    null, null, null, null);
    if (mCursor != null) {
    mCursor.moveToFirst();
    }
    return;


    Can anybody tell me what might be wrong on this one thanks

    Sean:confused:

  2. #2
    Join Date
    Jan 2011
    Posts
    5
    Rep Power
    0

    Default

    It was painful like finding a needle in a haystack but i managed to fix it!!!

    I was missing quotations around username in this line because it is a string

    Constants.USERNAME}, Constants.USERNAME + "=" + username, null,

    Thanks :)

Similar Threads

  1. android sdk
    By aizen92 in forum Android
    Replies: 2
    Last Post: 02-21-2011, 11:28 PM
  2. Android USB
    By Blackberrylerner in forum Android
    Replies: 0
    Last Post: 01-15-2011, 06:05 AM
  3. Android
    By sspkiet in forum Android
    Replies: 1
    Last Post: 09-03-2010, 02:14 AM
  4. Replies: 0
    Last Post: 06-25-2008, 01:41 PM
  5. Android on Eclipse 3.2
    By aibtus in forum Eclipse
    Replies: 0
    Last Post: 04-08-2008, 12:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •