The SQL statement is retrieving the ID of a row. But there may be no such row. When I executed a particular SQL statement in a GUI tool, it returned "0 rows returned in 0ms from:...".
However, when I executed the same SQL statement with ExecuteScalarAsync<int>, it returned 0, and no exception or null occurred. How do I know if there was no such row? Theoretically, there can be a row whose ID is 0.
PS: It is SQLite-net which I added using Nuget (https://github.com/praeclarum/sqlite-net). Its version is 1.4.118. The SQL statement was very simple one. I changed the field names, but basically it is something like:
using SQLite;
public Task<int> GetLastID()
{
return RealDatabase.ExecuteScalarAsync<int>
("SELECT max(ID) FROM DATA)");
}