C# – Android: How to port ExecuteScalar to Java?

Android: How to port ExecuteScalar to Java?… here is a solution to the problem.

Android: How to port ExecuteScalar to Java?

SqlCommand.ExecuteScalar Method
Executes the query, and returns
the first column of the first row in the result set returned by the
query. Additional columns or rows are ignored.

I guess this would make heavy use of generics.

Suppose I have a SQLiteDatabase/ Cursor object.

Solution

Look at SQLLiteStatement

long simpleQueryForLong() Execute a statement that returns a 1 by 1
table with a numeric value.

String simpleQueryForString() Execute a statement that returns a 1 by 1 table with a text value.

Related Problems and Solutions