1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-22 17:02:21 -05:00

Database: Helper method for loading an identity by id

This commit is contained in:
Sebastian Kaspari 2010-03-13 14:41:29 +01:00
parent 7c48f907d9
commit d82db7aa38

View File

@ -22,6 +22,7 @@ package org.yaaic.db;
import java.util.HashMap;
import org.yaaic.model.Identity;
import org.yaaic.model.Server;
import org.yaaic.model.Status;
@ -290,4 +291,37 @@ public class Database extends SQLiteOpenHelper
null
);
}
/**
* Get an identity by its id
*
* @param identityId
* @return
*/
public Identity getIdentityById(int identityId)
{
Cursor cursor = this.getReadableDatabase().query(
IdentityConstants.TABLE_NAME,
IdentityConstants.ALL,
IdentityConstants._ID + "=" + identityId,
null,
null,
null,
null
);
if (cursor.moveToNext()) {
Identity identity = new Identity();
identity.setNickname(cursor.getString(cursor.getColumnIndex(IdentityConstants.NICKNAME)));
identity.setIdent(cursor.getString(cursor.getColumnIndex(IdentityConstants.IDENT)));
identity.setRealName(cursor.getString(cursor.getColumnIndex(IdentityConstants.REALNAME)));
cursor.close();
return identity;
}
return null;
}
}