Add more fields of the Database

0

I have a model app that I downloaded to consult the SQLite database that shows me the Name and Address columns, everything works perfectly but I would like the Phone column to show me, I tried to modify the code but the problem is that when I add Telephone the Direccion column also becomes a phone number that appears twice the phone, could help me to detect the error that duplicates my phone column. Thanks

I tried removing the line namelist.put(cursor.getString(ii), cursor.getString(cursor.getColumnIndex("Telefonos"))); but with this I manage to repeat the Direction then

namelist=new LinkedHashMap<>();
    int ii;
    SQLiteDatabase sd = db.getReadableDatabase();
    Cursor cursor = sd.query("tabla_usuarios" ,null, null, null, null, null, null);
    ii=cursor.getColumnIndex("Nombre");
    nombrelist=new ArrayList<String>();
    dirlist= new ArrayList<String>();
    tellist= new ArrayList<String>();
    while (cursor.moveToNext()){
        namelist.put(cursor.getString(ii), cursor.getString(cursor.getColumnIndex("Direccion")));
        namelist.put(cursor.getString(ii), cursor.getString(cursor.getColumnIndex("Telefonos")));

    }
    Iterator entries = namelist.entrySet().iterator();
    while (entries.hasNext()) {
        Map.Entry thisEntry = (Map.Entry) entries.next();
        nombrelist.add(String.valueOf(thisEntry.getKey()));
        dirlist.add(String.valueOf(thisEntry.getValue()));
        tellist.add("* "+String.valueOf(thisEntry.getValue()));

    }
    
asked by Acertijo 05.09.2018 в 03:19
source

0 answers