Skip to content Skip to sidebar Skip to footer

Query "select Where" Return No Matched Data In Sqlite Android

i have a problem with query select where clause in sqlite. When i try to match the data from textView with database it's return no matched data. My query function public void cekP

Solution 1:

use like below:

Cursorcur= db.rawQuery("select * from task_table where alamat = '%" + 
        txtAlamat + "%'", null);

check this link there is example with LIKE Query. and hou use wildcards (missing letters in the pattern) in Query.

Edited:

    Cursor cursor = db.rawQuery("select * from task_table where alamat = '%" + 
            txtAlamat + "%'", null);
    if(cursor){
        Toast.makeText(this, "no data", Toast.LENGTH_LONG).show();
    }
    if (cursor.moveToFirst()) {
                do {
                      add = cur.getString(5);
                      if(!add.equalsIgnoreCase("")){
                         alarm = "Anda ada tugas di lokasi: " + add;
                      }else{
                         add = "Anda tidak ada tugas di lokasi sekarang";
                         alarm = "" + add;
                      }
                } while (cursor.moveToNext());
            }

Solution 2:

//cek tugasthis.cariTugas.setOnClickListener(newOnClickListener() {

        @OverridepublicvoidonClick(View v) {
            // TODO Auto-generated method stub
            txtAddr = teksAlamat.getText().toString().trim();
            Log.d("alamat textView", txtAddr);
            if(txtAddr != null && !txtAddr.equals("")){
                cekPosisi(txtAddr);
            }else{
                Log.d("","Please enter value again");
            }
          }
      });


//if you have data in the database then you will have values accordingly

Post a Comment for "Query "select Where" Return No Matched Data In Sqlite Android"