简体   繁体   中英

Retrieve data from Sqlite android in logcat

I wrote the following code to retrieve data from my database and show all the found objects in Log window, but it isn't showing..help?

public void afisareOferta() throws Exception {
    String selectQuery = " SELECT * FROM " + DBConst.tabela;
    Cursor cursor = db.rawQuery(selectQuery,null);
    String result;

    if(cursor.moveToFirst()) {
        do {
            //HomeExchange hm = new HomeExchange();
            result = cursor.getString(0) + cursor.getString(1) + cursor.getString(2) + cursor.getString(3 ) + cursor.getString(4);
           /* hm.setLocalitatea(cursor.getString(0));
            hm.setTipLocuinta(cursor.getString(1));
            hm.setNrCamere(cursor.getInt(2));
            hm.setData(cursor.getString(3));
            hm.setDurata(cursor.getInt(4));*/

            Log.i("Citire din bd:", result);

        }
        while (cursor.moveToNext());
    }
}

Logcat:

07-02 20:57:53.933 1969-1969/com.example.colega.restanta20182altfeldeafisaredata D/ViewRootImpl@9a0e50e[MainActivity]: ViewPostIme pointer 0
07-02 20:57:54.001 1969-1969/com.example.colega.restanta20182altfeldeafisaredata D/ViewRootImpl@9a0e50e[MainActivity]: ViewPostIme pointer 1
07-02 20:58:14.594 1969-1969/com.example.colega.restanta20182altfeldeafisaredata D/ViewRootImpl@9a0e50e[MainActivity]: ViewPostIme pointer 0
07-02 20:58:14.699 1969-1969/com.example.colega.restanta20182altfeldeafisaredata D/ViewRootImpl@9a0e50e[MainActivity]: ViewPostIme pointer 1

this shows up when i press the following button:

 bRead.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DBAdapter db = new DBAdapter(getApplicationContext());
            db.openConnection();
            try {
                db.afisareOferta();
            } catch (Exception e) {
                e.printStackTrace();
            }
            db.closeConnection();

        }
    });

In my opinion, you are not checking the proper logs in the logcat, as what you have qouted, are debug logs, please change your logcat to info and check as you are writing to info logs using the , Log.i() .

The logs you are seen are probably some other debug logs which are triggered by the same action. Check in here to know more about the logcat.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM