0

I am new to mobile application design , I am trying to design an android , I use a database sqlite , my only problem is the query I have a table and I want to select all the names in this table whose id is 1

I'm tried this, but I know it's totaly false!

String selectQuery = "SELECT" +KEY_ARRET +" FROM " + TABLE_NAME + "where _idligne "  = ' " +1+ '";

   SQLiteDatabase db = this.getReadableDatabase();
   Cursor cursor = db.rawQuery(selectQuery, null);

Thank you for your help ! :)

2 Answers 2

1
String selectQuery = "SELECT " + KEY_ARRET + " FROM " + TABLE_NAME + " WHERE _idligne = 1";
Sign up to request clarification or add additional context in comments.

1 Comment

thank you very much for your answer, but it still does not work
0

try this way, less lines but is the same, without the mistake of course:

Cursor cursor = db.rawQuery("SELECT "+ KEY_ARRENT+" FROM "+TABLE_NAME+"WHERE _idligne = 1", null);

in case it dosen't works try this one:

cursor = db.rawQuery("select * from "+TABLE_NAME+" WHERE _idligne = 1", null);
String C1="";
        if (cursor.getCount() != 0) {//recorre todos los datos/campos
            if (cursor.moveToFirst()) {
                do {
                    C1 = cursor.getString(cursor
                            .getColumnIndex(KEY_ARRENT));
                } while (cursor.moveToNext());//pasa al sig dato /campo
            }
        }
        cursor.close();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.