mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
simplify cursor code
This commit is contained in:
parent
bfe04a08b5
commit
d3bb7d490a
1 changed files with 11 additions and 32 deletions
|
@ -436,17 +436,9 @@ public class DBUtils {
|
|||
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||
selection, null, null, null, null );
|
||||
|
||||
if ( 0 < cursor.getCount() ) {
|
||||
cursor.moveToFirst();
|
||||
for ( ; ; ) {
|
||||
ids.add( cursor.
|
||||
getString( cursor.
|
||||
while ( cursor.moveToNext() ) {
|
||||
ids.add( cursor.getString( cursor.
|
||||
getColumnIndex(DBHelper.RELAYID)) );
|
||||
if ( cursor.isLast() ) {
|
||||
break;
|
||||
}
|
||||
cursor.moveToNext();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
|
@ -491,17 +483,12 @@ public class DBUtils {
|
|||
Cursor cursor = db.query( DBHelper.TABLE_NAME_OBITS, columns,
|
||||
null, null, null, null, null );
|
||||
if ( 0 < cursor.getCount() ) {
|
||||
cursor.moveToFirst();
|
||||
for ( ; ; ) {
|
||||
int index = cursor.getColumnIndex( DBHelper.RELAYID );
|
||||
String relayID = cursor.getString( index );
|
||||
index = cursor.getColumnIndex( DBHelper.SEED );
|
||||
int seed = cursor.getInt( index );
|
||||
int idIndex = cursor.getColumnIndex( DBHelper.RELAYID );
|
||||
int seedIndex = cursor.getColumnIndex( DBHelper.SEED );
|
||||
while ( cursor.moveToNext() ) {
|
||||
String relayID = cursor.getString( idIndex );
|
||||
int seed = cursor.getInt( seedIndex );
|
||||
al.add( new Obit( relayID, seed ) );
|
||||
if ( cursor.isLast() ) {
|
||||
break;
|
||||
}
|
||||
cursor.moveToNext();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
|
@ -649,17 +636,9 @@ public class DBUtils {
|
|||
null, null, null, null, orderBy );
|
||||
int count = cursor.getCount();
|
||||
result = new long[count];
|
||||
if ( 0 < count ) {
|
||||
int index = cursor.getColumnIndex( ROW_ID );
|
||||
cursor.moveToFirst();
|
||||
|
||||
for ( int ii = 0; ; ++ii ) {
|
||||
for ( int ii = 0; cursor.moveToNext(); ++ii ) {
|
||||
result[ii] = cursor.getLong( index );
|
||||
if ( cursor.isLast() ) {
|
||||
break;
|
||||
}
|
||||
cursor.moveToNext();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
|
|
Loading…
Reference in a new issue