[android-developers] Re: How to query the number of rows in a table

2009-05-04 Thread Marco Nelissen
On Mon, May 4, 2009 at 1:17 PM, Lucius Fox  wrote:

>
> On Mon, May 4, 2009 at 9:58 AM, Marco Nelissen 
> wrote:
> > select count(*) from table
> > See also http://sqlite.org/lang.html
> >
>
> Thank you. Here is what i try:
>
> public void getRow(SQLiteDatabase db)  {
>  db.beginTransaction();
>try {
>
>db.execSQL("select count(*) from mytable");
>db.setTransactionSuccessful();
>version = 3;
>} catch (SQLException ex) {
>
>Log.e(LOG_TAG, ex.getMessage(), ex);
>} finally {
>db.endTransaction();
>}
>
> }
>
> but how can I get the actual result from the 'execSQL' ?


Use db.rawQuery() instead and retrieve the value from the resulting Cursor.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to query the number of rows in a table

2009-05-04 Thread Lucius Fox

On Mon, May 4, 2009 at 9:58 AM, Marco Nelissen  wrote:
> select count(*) from table
> See also http://sqlite.org/lang.html
>

Thank you. Here is what i try:

public void getRow(SQLiteDatabase db)  {
 db.beginTransaction();
try {

db.execSQL("select count(*) from mytable");
db.setTransactionSuccessful();
version = 3;
} catch (SQLException ex) {

Log.e(LOG_TAG, ex.getMessage(), ex);
} finally {
db.endTransaction();
}

}

but how can I get the actual result from the 'execSQL' ?

Thank you.





> On Mon, May 4, 2009 at 9:51 AM, Lucius Fox  wrote:
>>
>> Hi,
>>
>> Can you please tell me how to query the number of rows in a table in
>> Android? Assume I have the name of the table in string.
>>
>> Thank you.
>>
>>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to query the number of rows in a table

2009-05-04 Thread Marco Nelissen
select count(*) from table
See also http://sqlite.org/lang.html

On Mon, May 4, 2009 at 9:51 AM, Lucius Fox  wrote:

>
> Hi,
>
> Can you please tell me how to query the number of rows in a table in
> Android? Assume I have the name of the table in string.
>
> Thank you.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---