lundi 4 mai 2015

Get single value from database and convert to string

At current i have a app that grabs data from a online source and converts it into a string. Now what i want to do is compare if its the same as the one in my database.

The part that im struggling with is that i dont know how to reliably get that data from the database.

(i want to test and see if the sting is equal to 2015-04-28 12:27:28) bellow is the data in the database

id2 LastEdit
1   2015-04-28 12:27:28

i have got a fetch methord

public Cursor fetch2() {
        String[] columns = new String[] { DatabaseHelper._ID2, DatabaseHelper.TUT_EDIT };
        Cursor cursor = database.query(DatabaseHelper.TABLE_NAME2, columns, null, null, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
        }
        return cursor;
    }

but im not sure how to grab the data reliably when im not converting it straight into a R.id.() array.

EDIT: as in the bellow

final String[] from = new String[] { DatabaseHelper._ID,
            DatabaseHelper.TUT_EDIT};


    final int[] to = new int[] { R.id.pid, R.id.edit };

Thank you for your time.

Aucun commentaire:

Enregistrer un commentaire