mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-29 10:26:36 +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,
|
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||||
selection, null, null, null, null );
|
selection, null, null, null, null );
|
||||||
|
|
||||||
if ( 0 < cursor.getCount() ) {
|
while ( cursor.moveToNext() ) {
|
||||||
cursor.moveToFirst();
|
ids.add( cursor.getString( cursor.
|
||||||
for ( ; ; ) {
|
getColumnIndex(DBHelper.RELAYID)) );
|
||||||
ids.add( cursor.
|
|
||||||
getString( cursor.
|
|
||||||
getColumnIndex(DBHelper.RELAYID)) );
|
|
||||||
if ( cursor.isLast() ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cursor.moveToNext();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
db.close();
|
db.close();
|
||||||
|
@ -491,17 +483,12 @@ public class DBUtils {
|
||||||
Cursor cursor = db.query( DBHelper.TABLE_NAME_OBITS, columns,
|
Cursor cursor = db.query( DBHelper.TABLE_NAME_OBITS, columns,
|
||||||
null, null, null, null, null );
|
null, null, null, null, null );
|
||||||
if ( 0 < cursor.getCount() ) {
|
if ( 0 < cursor.getCount() ) {
|
||||||
cursor.moveToFirst();
|
int idIndex = cursor.getColumnIndex( DBHelper.RELAYID );
|
||||||
for ( ; ; ) {
|
int seedIndex = cursor.getColumnIndex( DBHelper.SEED );
|
||||||
int index = cursor.getColumnIndex( DBHelper.RELAYID );
|
while ( cursor.moveToNext() ) {
|
||||||
String relayID = cursor.getString( index );
|
String relayID = cursor.getString( idIndex );
|
||||||
index = cursor.getColumnIndex( DBHelper.SEED );
|
int seed = cursor.getInt( seedIndex );
|
||||||
int seed = cursor.getInt( index );
|
|
||||||
al.add( new Obit( relayID, seed ) );
|
al.add( new Obit( relayID, seed ) );
|
||||||
if ( cursor.isLast() ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cursor.moveToNext();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -649,17 +636,9 @@ public class DBUtils {
|
||||||
null, null, null, null, orderBy );
|
null, null, null, null, orderBy );
|
||||||
int count = cursor.getCount();
|
int count = cursor.getCount();
|
||||||
result = new long[count];
|
result = new long[count];
|
||||||
if ( 0 < count ) {
|
int index = cursor.getColumnIndex( ROW_ID );
|
||||||
int index = cursor.getColumnIndex( ROW_ID );
|
for ( int ii = 0; cursor.moveToNext(); ++ii ) {
|
||||||
cursor.moveToFirst();
|
result[ii] = cursor.getLong( index );
|
||||||
|
|
||||||
for ( int ii = 0; ; ++ii ) {
|
|
||||||
result[ii] = cursor.getLong( index );
|
|
||||||
if ( cursor.isLast() ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cursor.moveToNext();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
db.close();
|
db.close();
|
||||||
|
|
Loading…
Reference in a new issue