mardi 15 décembre 2015

Fetch Date from database that is shipped with android app

I am following this tutorial http://ift.tt/1K2Tei9 to have an external database with my android app.

I am not able to apply where clause while fetching the data from the database. This is what I have done so far.

c=myDbHelper.query("level1", null, "_id=2", null, null,null, null);
    if(c.moveToFirst())
   {
       do {

        Toast.makeText(Level1.this,
                   "_id: " + c.getString(0) + "\n" +
                   "name: " + c.getString(1) + "\n" 
                   ,
                   Toast.LENGTH_LONG).show();

       } while (c.moveToNext());
   }

The databaseHelper class

public Cursor query(String table,String[] columns, String selection,String[] selectionArgs,String groupBy,String having,String orderBy){
    return myDataBase.query("level1", null, "_id", null, null, null, null);


}

Can anyone help me with this?

Aucun commentaire:

Enregistrer un commentaire