Q:

Login system using database

I want to create simple login system using the SQLLIte I have created the database but I got an error in the cursor.
My database code is
public static final String KEY_RAWID = "_id";
    public static final String KEY_RAWNAME = "name";
    public static final String KEY_PASSWORD = "password";
    public static final String KEY_EMAIL = "email";
        private static final String DATABASE_NAME = "users_DB";
    private static final String DATABASE_TABLE = "users";
    private dbusers ourhelper;
    private final Context ourcontext;
    private SQLiteDatabase ourDatabase;

    private static class dbusers extends SQLiteOpenHelper {

        public dbusers(Context context) {
            super(context, DATABASE_TABLE, null, DATABASE_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub

            db.execSQL("CREATE TABLE " + DATABASE_TABLE + "(" + KEY_RAWID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " +    KEY_RAWNAME
                    + " TEXT NOT NULL, " + KEY_PASSWORD + " TEXT NOT   NULL, "
                    + KEY_EMAIL + " TEXT NOT NULL);");

        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub
            db.execSQL("DROP TABLE IF EXISTS" + DATABASE_TABLE);
            onCreate(db);
        }

    }

    public Dbinfo(Context c) {
        ourcontext = c;
    }

    public Dbinfo open() {
        ourhelper = new dbusers(ourcontext);
        ourDatabase = ourhelper.getWritableDatabase();
        return this;
    }

    public void close() {
        ourhelper.close();
    }

I got error in this function
public Boolean check(String nameS, String passwordS) {
        // TODO Auto-generated method stub
        String[] columns = new String[] { KEY_RAWID, KEY_RAWNAME, KEY_PASSWORD,
                KEY_EMAIL };
        Cursor c = null;
        Boolean check = true;

        c=ourDatabase.rawQuery("SELECT name,password FROM users WHERE name="+nameS,null);

        if (c.getCount() > 0)// && c2.getCount() > 0) {
        {   check = false;
            return check;
        }

        return check;

The error:
04-15 00:29:23.302: E/AndroidRuntime(1300): android.database.sqlite.SQLiteException: no such column: khaled: , while compiling: SELECT name,password FROM users WHERE name=khaled

Although I have added data in the database and I have checked that the data in the database is successfully added. Any help?

A:

This line needs to be changed from:    
c=ourDatabase.rawQuery("SELECT name,password FROM users WHERE name="+nameS,null);

to
c=ourDatabase.rawQuery("SELECT name,password FROM users WHERE name='"+nameS+"'",null);

