Here you can find the source of getNewTourPointPosition(SQLiteDatabase db, long tourId)
private static int getNewTourPointPosition(SQLiteDatabase db, long tourId)
//package com.java2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class Main { protected final static String TOUR_POINT_TABLE_NAME = "TourPoint"; protected final static String TOUR_POINT_TOUR_ID = "tourId"; protected final static String TOUR_POINT_POSITION = "position"; private static int getNewTourPointPosition(SQLiteDatabase db, long tourId) { Cursor cursor = db.query(TOUR_POINT_TABLE_NAME, new String[] { "max(" + TOUR_POINT_POSITION + ")" }, TOUR_POINT_TOUR_ID + "=" + tourId, null, null, null, null); cursor.moveToFirst();/* w w w .ja v a2 s . com*/ int position = cursor.getInt(0); cursor.close(); return ++position; } }