title: How to get row number from sqlite in android?
body: <p>Hello stackoverflow community,
  I have a problem in Android especially with SQLite. I've created an App where you can create a ToDo List. I work in this app with a ContentResolver and the list is displayed in a simple ListView. <a href="https://i.stack.imgur.com/H8RLx.png" rel="nofollow noreferrer">Actual Layout</a>.
  The List is orderd with through the Cursor LoaderManager and has a ascending order.  The projection is the following:</p>
  
  <pre><code>String[] projection = {
              ToDoContract._ID,
              ToDoContract.COLUMN_IMAGE,
              ToDoContract.COLUMN_HEADLINE,
              ToDoContract.COLUMN_DESCRIPTION,
              ToDoContract.COLUMN_PRIORITY,
              ToDoContract.COLUMN_WEEKDAY,
              ToDoContract.COLUMN_DONE
      };
      String sortOrder = ToDoContract.COLUMN_WEEKDAY + " ASC";
  </code></pre>
  
  <p>The Weekdays are integers(1=monday, 7=sunday) because i didn't know another way to sort the weekdays. </p>
  
  <p>My Problem is the following: 
  I want to delete or edit these entries and i don't know how to get the row number of the entry. The ListView is registered for a ContextMenu.
  Here is an example: 
  I get the ContextMenu position with the following code: </p>
  
  <pre><code>AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
      int index = info.position;
  </code></pre>
  
  <p>Now I have the position inside the ListView but i need the position in the sqlite database. My normal way was that i create a Uri with an appended ID</p>
  
  <pre><code>Uri currentListUri = ContentUris.withAppendedId(ToDoContract.CONTENT_URI, index);
  </code></pre>
  
  <p>But since my list is ordered, the way doesn't work. The ID in SQLite might be 4 and in my ListView it's 1. Has anybody a hint how to get the ordered position?</p>
  
  <p>Edit:</p>
  
  <p>Just make it clear, i already get the count of my database through this method:</p>
  
  <pre><code>TableDBHelper dbHelper = new TableDBHelper(getContext());
  long count = dbHelper.getTodoCount();
  </code></pre>
  
  <p>And getTodoCount(); is the following:</p>
  
  <pre><code>public long getTodoCount() {
  SQLiteDatabase db = this.getReadableDatabase();
  long count = DatabaseUtils.queryNumEntries(db, ToDoContract.TABLE_NAME);
  db.close();
  return count;
  </code></pre>
  
  <p>}</p>