Note that there are some explanatory texts on larger screens.

plurals
  1. PO getting next value in android using SQLite
    primarykey
    data
    text
    <p>I have doing small application in android.During this application, i have suffer this problem:</p> <p>I search the keyword using "<strong>oh</strong>" then i listing in to listview using this code. </p> <pre><code>nameList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { try { Intent intent = new Intent(Search.this, SearchDetails.class); /* * Cursor cursor = (Cursor) adapter.getItem(position); * intent.putExtra("JOK_ID", * cursor.getInt(cursor.getColumnIndex("_id"))); */ intent.putExtra("id", id); intent.putExtra("position", position); Log.d(TAG, " I.." + id); Log.d(TAG, " P.." + position); startActivity(intent); } catch (Exception e) { e.printStackTrace(); } } }); } </code></pre> <p>for example like this <img src="https://i.stack.imgur.com/zepV3.jpg" alt="enter image description here"></p> <p>Now, if I click <strong>oham</strong> then display just like this: <img src="https://i.stack.imgur.com/wpGSB.jpg" alt="enter image description here"></p> <p>Finally, I want to , If i click previous button then display <strong>john</strong> and Next to display <strong>krackohm</strong>. And count total number of searched names. I have try this code for next button:</p> <pre><code> Cursor cursor = db.rawQuery("SELECT _id, name FROM std WHERE _id = ?", new String[]{""+Id}); if (cursor.getCount() == 1) { cursor.moveToFirst(); ...body } </code></pre> <p><strong>Edit:</strong></p> <p>This is first time when any list item click, on create</p> <pre><code> private void dislpayFirstName() { // this is display first time click list item writeDatabase(); cursor = db.rawQuery("SELECT _id, name FROM std WHERE._id = ?", new String[]{""+Id}); if (cursor.getCount()&gt; 0) { cursor.moveToFirst(); nameDetails(); } } </code></pre> <p>This is the code for Next Button click:</p> <pre><code> position++; writeDatabase(); cursor = db.rawQuery("SELECT _id,name FROM std", null); if (cursor.getCount()&gt; 0) { cursor.moveToPosition(position); //cursor.moveToNext(); nameDetails(); } </code></pre> <p>In next button: If <strong>cursor.moveToPosition(position);</strong> then next name display matching position and table id. Means postion 2 then display 2 number name from table.</p> <p>In next button: If <strong>cursor.moveToNext();</strong> then next name display beginning of table.Means 0 id name from table.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload