0
這是我的方法,該方法返回MAX(_id)
的Android SQLite的最大回報127
public static int getMaxId(Context context, Uri uri, String columnName) {
//it is all
String []projection = new String[]{"MAX("+ columnName +")"};
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
cursor.moveToFirst();
return cursor.getInt(0);
}
如果在數據庫中的記錄數<127
一切正常,但如果記錄>127
數(例如250或500),該方法返回127
。
集合函數max()
返回組中所有值的最大值。最大值是最後在同一列上的ORDER BY
中返回的值。當且僅當該組中沒有non-NULL
值時,聚合max()
返回NULL
。