jeudi 17 décembre 2015

SQLite querys android, what does mean the rawQuery parameters?

I have this code :

       ArrayList<HashMap<String, String>> res  = new ArrayList<HashMap<String, String>>();
    try {
        String query = "SELECT \n" +
                "launchers.laun_id,\n" +
                "laun_name,\n" +
                "IFNULL(laun_description,''),\n" +
                "IFNULL(laun_options,'')\n" +
                "FROM launchers\n" +
                "INNER JOIN users_launchers ON (users_launchers.laun_id=launchers.laun_id)";
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery(query, null);
        if (cursor.moveToFirst()) {
            do {
                HashMap<String, String> f = new HashMap<String, String>();
                f.put("id",cursor.getString(0));
                f.put("name",cursor.getString(1));
                f.put("description",cursor.getString(2));
                f.put("options",cursor.getString(3));

                res.add(f);
            } while (cursor.moveToNext());
        }
        db.close();
    } catch (Exception e) {
           .......another big code
    }
     return res;

I see that the query variable has the query for the first row and then the cursor uses .rawQuery, what does rawQuery do?? and then it recieves two parameters, what they do?? and at the final of the do/while cycle there is a line : res.add(f);

what does it do?? is like adding a hashmap inside of a ArrayList of hashmap ????

Aucun commentaire:

Enregistrer un commentaire