mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
use order-by so don't have to iterate over results
This assumes, as seems to be the case, that rowid is assigned increasing order.
This commit is contained in:
parent
fbc8a62a13
commit
3510268752
1 changed files with 9 additions and 13 deletions
|
@ -2265,22 +2265,18 @@ public class DBUtils {
|
||||||
private static String getStringForSyncSel( SQLiteDatabase db, String selection )
|
private static String getStringForSyncSel( SQLiteDatabase db, String selection )
|
||||||
{
|
{
|
||||||
String result = null;
|
String result = null;
|
||||||
String[] columns = { ROW_ID, DBHelper.VALUE };
|
String[] columns = { DBHelper.VALUE, };
|
||||||
|
|
||||||
Cursor cursor = DBHelper.query( db, TABLE_NAMES.PAIRS, columns, selection );
|
|
||||||
// Log.d( TAG, "getStringForSyncSel(selection=%s)", selection );
|
|
||||||
boolean tooMany = BuildConfig.DEBUG && 1 < cursor.getCount();
|
|
||||||
|
|
||||||
// If there are multiple matches, we want to use the newest. At least
|
// If there are multiple matches, we want to use the newest. At least
|
||||||
// that's the right move where a devID's key has been changed with
|
// that's the right move where a devID's key has been changed with
|
||||||
// each upgrade.
|
// each upgrade.
|
||||||
long prevRow = 0;
|
String orderBy = ROW_ID + " DESC";
|
||||||
while ( cursor.moveToNext() ) {
|
|
||||||
long row = cursor.getLong(cursor.getColumnIndex(ROW_ID));
|
Cursor cursor = DBHelper.query( db, TABLE_NAMES.PAIRS, columns, selection, orderBy );
|
||||||
if ( row > prevRow ) {
|
// Log.d( TAG, "getStringForSyncSel(selection=%s)", selection );
|
||||||
|
boolean tooMany = BuildConfig.DEBUG && 1 < cursor.getCount();
|
||||||
|
|
||||||
|
if ( cursor.moveToNext() ) {
|
||||||
result = cursor.getString( cursor.getColumnIndex(DBHelper.VALUE) );
|
result = cursor.getString( cursor.getColumnIndex(DBHelper.VALUE) );
|
||||||
prevRow = row;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue