Insert data in TableModel.addRow into Blackberry TableView - blackberry

I need to Create a table where 3 columns are needed and can have multiple rows. I am using BlackBerry API version 6. I have debugged my code and it's giving IllegalArgumentException. I am not able to sort this error out.
My code is as follows:
public class designTableLayout extends MainScreen{
TableModel theModel = new TableModel();
theView = new TableView(theModel);
TableController theController = new TableController(theModel, theView,
TableController.FIELD_FOCUS);
theView.setController(theController);
HeaderTemplate theTemplate = new HeaderTemplate(theView, 1, 3);
theTemplate.createRegion(new XYRect(0,0,1,1));
theTemplate.createRegion(new XYRect(1,0,1,1));
theTemplate.createRegion(new XYRect(2,0,1,1));
theTemplate.setRowProperties(0, new TemplateRowProperties(60));
theTemplate.setColumnProperties(0, new TemplateColumnProperties(40));
theTemplate.setColumnProperties(1, new TemplateColumnProperties(40));
theTemplate.setColumnProperties(2, new TemplateColumnProperties(40));
theTemplate.useFixedHeight(true);
theView.setDataTemplate(theTemplate);
theModel.addRow(new String[]{"the","quick","brown"});// problem arises here
theModel.addRow(new String[]{"jumps","over","the"});
theModel.addRow(new String[]{"dog","the","quick"});
add(theView);
}
class HeaderTemplate extends DataTemplate {
LabelField field1 = new LabelField("field1");
LabelField field2 = new LabelField("field2");
LabelField field3 = new LabelField("field3");
public HeaderTemplate(DataView view,int rows,int columns){
super(view, rows, columns);
}
public Field[] getDataFields(int modelRowIndex) {
TableModel theModel = (TableModel) getView().getModel();
//Get the data for the row.
Object[] data = {field1, field2, field3};
data = (Object[]) theModel.getRow(modelRowIndex);
//Create a array to hold all fields.
Field[] theDataFields = new Field[data.length];
theDataFields[0] = new LabelField(field1/*, DrawStyle.ELLIPSIS*/);
theDataFields[1] = new LabelField(field2/*, DrawStyle.ELLIPSIS*/);
theDataFields[2] = new LabelField(field3/*, DrawStyle.ELLIPSIS*/);
return theDataFields;
}
}

I know you probably are using some of this code just to test your table model, but I think your template should look more like this:
class HeaderTemplate extends DataTemplate {
public HeaderTemplate(DataView view,int rows,int columns){
super(view, rows, columns);
}
public Field[] getDataFields(int modelRowIndex) {
TableModel theModel = (TableModel) getView().getModel();
//Get the data for the row.
Object[] data = (Object[]) theModel.getRow(modelRowIndex);
//Create a array to hold all fields.
Field[] theDataFields = new Field[data.length];
theDataFields[0] = new LabelField((String)data[0], DrawStyle.ELLIPSIS);
theDataFields[1] = new LabelField((String)data[1], DrawStyle.ELLIPSIS);
theDataFields[2] = new LabelField((String)data[2], DrawStyle.ELLIPSIS);
return theDataFields;
}
}
And then add your data as an Object[]:
theModel.addRow(new Object[]{"the","quick","brown"});
Here is the BlackBerry example on this

Related

storing data in persistence store

I am facing an issue in storing data in persistence store,i am trying to store events for different dates in persistence store but the data is getting overridden the code is :
public ListEventScreen(Vector v,String timezone) {
for(int i=0;i<v.size();i++){
EventBean bean=(EventBean)v.elementAt(i);
//a normal label in the app, just to display text, anchored left
LabelField label = new LabelField(bean.getSummary(),LabelField.FIELD_LEFT);
//add the label to the screen
add(label);
saveUserInfo(v);
}
}
public void saveUserInfo(Vector vectorData){
// static{
store = PersistentStore.getPersistentObject( 0x1dfc10ec9447eb14L );
synchronized(store) {
store.setContents(vectorData);
store.commit();
}
//}
}
Please let me know what has to be changed.
Every time you call store.setContents(), the current contents of the persistentStore are overwritten with the Vector you are passing in. You need to make sure you are loading the previous events that were already in the persistentStore into your Vector before then adding new events into that Vector that you are then saving.
You are also calling saveUserInfo() on every iteration of your loop in ListEventScreen(). You should be calling it outside of the loop instead.
I would do something like this:
public ListEventScreen(Vector v,String timezone) {
Enumeration e = v.elements();;
while (e.hasMoreElements()){
EventBean bean = (EventBean) e.nextElement();
//a normal label in the app, just to display text, anchored left
LabelField label = new LabelField(bean.getSummary(),LabelField.FIELD_LEFT);
//add the label to the screen
add(label);
}
}
public void loadUserInfo(Vector vectorData){
// static{
store = PersistentStore.getPersistentObject( 0x1dfc10ec9447eb14L );
synchronized(store) {
Vector v = (Vector) store.getContents();
Enumeration e = v.elements();
while (e.hasMoreElemens){
vectorData.add(e.nextElement());
}
}
//}
}
public void saveUserInfo(Vector vectorData){
// static{
store = PersistentStore.getPersistentObject( 0x1dfc10ec9447eb14L );
synchronized(store) {
store.setContents(vectorData);
store.commit();
}
//}
}
.
{
Vector v = new Vector();
loadUserInfo(v);
ListEventScreen(v, ...);
... modify v contents as needed ...
saveUserInfo(v);
}
If you do not mind changing the format of your persistent store contents, I would wrap the store in a singleton class instead:
public class EventBeans extends Vector implements Persistable
{
private static final long persistKey = 0x1dfc10ec9447eb14L;
private static EventBeans _instance = null;
private static PersistentObject _persist = null;
static{
_persist = PersistentStore.getPersistentObject(persistKey);
_instance = (EventBeans) _persist.getContents();
if (_instance == null){
_instance = new EventBeans();
_persist.setContents(_instance);
_persist.commit();
}
}
private EventBeans(){
super();
}
public static EventBeans getInstance(){
return _instance;
}
public static synchronized void save(){
_persist.commit();
}
}
.
{
Vector v = EventBeans.getInstance();
ListEventScreen(v, ...);
... modify v contents as needed ...
EventBeans.save();
}

how to set focus on tab till another tab is not selected in blackberry

I am using PaneManagerDemo project code (this project is present in sample demo projects of BB) for developing tab.
I am facing one problem when I select tab it got focus but when I select data below that tab the focus goes to that data.
I want when user select data under tab, it must focus on that data as well as the tab so that user can understand selected data is under which tab.
I am not getting it.
Please tell me.
Here is code for the reference.
public class PaneManagerDemo extends UiApplication
{
public static void main(String[] args)
{
UiApplication app = new PaneManagerDemo();
app.enterEventDispatcher();
}
public PaneManagerDemo()
{
invokeLater(new Runnable()
{
public void run()
{
int headerType = 0;
// Display a dialog for user to select header type
OptionDialog dialog = new OptionDialog();
int result = dialog.doModal();
if(result == Dialog.OK)
{
headerType = dialog.getHeaderType();
}
else if(result == Dialog.CANCEL)
{
System.exit(0);
}
//PaneScreen screen = new PaneScreen(headerType);
PaneScreen screen = new PaneScreen(headerType);
pushScreen(screen);
}
});
}
/**
* A dialog popup used to choose a header type
*/
private static class OptionDialog extends Dialog
{
public static final int SCROLL_HEADER_TYPE = 0;
public static final int TAB_HEADER_TYPE = 1;
private ObjectChoiceField _choiceField;
/**
* Create a new HeaderDialog object
*/
public OptionDialog()
{
super(Dialog.D_OK_CANCEL, "Choose Header Type", Dialog.OK, null, Dialog.GLOBAL_STATUS);
_choiceField = new ObjectChoiceField("", new String[]{"Scrollable", "Tab"}, 0);
add(_choiceField);
_choiceField.setFocus();
}
/**
* Returns an integer representing the header type
*
* #return SCROLL_HEADER_TYPE if scrollable header selected, TAB_HEADER_TYPE if tab header selected
*/
public int getHeaderType()
{
return _choiceField.getSelectedIndex();
}
}
/**
* Main screen for the application. Displays three panes
* switchable via horizontal scroll field or tabs, depending
* on user selection.
*/
private final static class PaneScreen extends MainScreen
{
/**
* Creates a new PaneScreen object
* #param headerType The header type for the PaneManager, scrollable or tab style
*/
public PaneScreen(int headerType)
{
super(Field.FOCUSABLE);
// Instantiate the model for the pane manager and enable looping
PaneManagerModel model = new PaneManagerModel();
model.enableLooping(true);
// Create a pane
VerticalFieldManager vfm = new VerticalFieldManager();
vfm.add(new LabelField("Data 1"));
XYEdges edgesOne = new XYEdges(1, 1, 1, 1);
vfm.setBorder(BorderFactory.createRoundedBorder(edgesOne));
Pane pane = new Pane(new LabelField("Pane 1", Field.FOCUSABLE | Field.FIELD_HCENTER), vfm);
// Add the pane to the model
model.addPane(pane);
// Create a second pane
vfm = new VerticalFieldManager();
for(int i = 0; i < 30; i++)
{
vfm.add(new LabelField("Data " + i, Field.FOCUSABLE));
}
LabelField iconTextLabelField = new LabelField("Pane 2");
model.addPane(new Pane(iconTextLabelField, vfm));
// Create a third pane
vfm = new VerticalFieldManager();
ButtonField button = new ButtonField("Button", ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY);
button.setChangeListener( new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
Dialog.inform("Button activated.");
}
});
vfm.add(button);
model.addPane(new Pane(new LabelField("Pane 3"), vfm));
// Choose which pane the model is displaying
model.setCurrentlySelectedIndex(1);
// Create the header and initialize the model and visual properties
TitleView header = null;
PaneManagerController controller = null;
if(headerType == OptionDialog.SCROLL_HEADER_TYPE)
{
header = new HorizontalScrollableTitleView(Field.FOCUSABLE);
controller = new HorizontalScrollableController();
}
else if(headerType == OptionDialog.TAB_HEADER_TYPE)
{
header = new HorizontalTabTitleView(Field.FOCUSABLE);
((HorizontalTabTitleView)header).setNumberOfDisplayedTabs(model.numberOfPanes());
controller = new HorizontalTabController();
}
else
{
throw new IllegalStateException("Header type is not valid.");
}
header.setModel(model);
XYEdges edgesFour = new XYEdges(4, 4, 4, 4);
header.setBorder(BorderFactory.createRoundedBorder(edgesFour));
// Set arrow images
Bitmap leftArrow = Bitmap.getBitmapResource("leftArrow.png");
Bitmap rightArrow = Bitmap.getBitmapResource("rightArrow.png");
if(leftArrow != null)
{
header.setLeftArrow(leftArrow);
}
if(rightArrow != null)
{
header.setRightArrow(rightArrow);
}
// Create the PaneView object, which will display the panes and is
// controlled by the model.
PaneView paneView = new PaneView(Field.FOCUSABLE);
paneView.setBorder(BorderFactory.createSimpleBorder(edgesOne));
paneView.setModel(model);
// Initialize the PaneManagerView
PaneManagerView view = new PaneManagerView(Field.FOCUSABLE, header, paneView);
view.setModel(model);
view.setBorder(BorderFactory.createRoundedBorder(edgesFour));
model.setView(view);
// Initialize the Controller
controller.setModel(model);
controller.setView(view);
model.setController(controller);
view.setController(controller);
add(view);
}
}
}
Only one field in a screen can hold focus at any one time, so you will need to indicate which tab contains the focused field by other means. e.g. by painting the selected tab a different colour.

Backup/Restore net.rim.device.api.util.Persitable object with DesktopManger

The task is to backup/restore Persistable object with BB Desktop Manager or in any other way. The main aim is to keep data between device firmware updates...
I have:
public final class UserList implements Persistable {
//The persistable objects.
private Hashtable fData;
//Initialize the class with empty values.
public UserList() {
fData = new Hashtable();
}
//Initialize the class with the specified values.
public UserList(Hashtable p) {
fData = p;
}
public Hashtable getData() {
return fData;
}}
I also have implemented SyncItem (as found in one of the examples)
public final class UserListSync extends SyncItem {
private static UserList fList;
private static final int FIELDTAG_NAME = 1;
private static final int FIELDTAG_AGE = 2;
private static PersistentObject store;
static {
store = PersistentStore.getPersistentObject(0x3167239af4aa40fL);
}
public UserListSync() {
}
public String getSyncName() {
return "Sync Item Sample";
}
public String getSyncName(Locale locale) {
return null;
}
public int getSyncVersion() {
return 1;
}
public boolean getSyncData(DataBuffer db, int version) {
boolean retVal = true;
synchronized (store) {
if (store.getContents() != null) {
fList = (UserList)store.getContents();
}
}
try {
Enumeration e = fList.getData().keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String value = (String) fList.getData().get(key);
//Write the name.
db.writeShort(key.length() + 1);
db.writeByte(FIELDTAG_NAME);
db.write(key.getBytes());
db.writeByte(0);
//Write the age.
db.writeShort(value.length() + 1);
db.writeByte(FIELDTAG_AGE);
db.write(value.getBytes());
db.writeByte(0);
}
} catch (Exception e) {
retVal = false;
}
return retVal;
}
//Interprets and stores the data sent from the Desktop Manager.
public boolean setSyncData(DataBuffer db, int version) {
int length;
Hashtable table = new Hashtable();
Vector keys = new Vector();
Vector values = new Vector();
boolean retVal = true;
try {
//Read until the end of the Databuffer.
while (db.available() > 0) {
//Read the length of the data.
length = db.readShort();
//Set the byte array to the length of the data.
byte[] bytes = new byte[length];
//Determine the type of data to be read (name or age).
switch (db.readByte()) {
case FIELDTAG_NAME:
db.readFully(bytes);
keys.addElement(new String(bytes).trim());
break;
case FIELDTAG_AGE:
db.readFully(bytes);
values.addElement(new String(bytes).trim());
break;
}
}
} catch (Exception e) {
retVal = false;
}
for (int i = 0; i < keys.size(); i++) {
table.put(keys.elementAt(i), values.elementAt(i));
}
try {
//Store the new data in the persistent store object.
fList = new UserList(table);
store.setContents(fList);
store.commit();
} catch (Exception e) {
retVal = false;
}
return retVal;
}}
The entry poing is following:
public class SyncItemSample extends UiApplication {
private static PersistentObject store;
private static UserList userList;
static {
store = PersistentStore.getPersistentObject(0x3167239af4aa40fL);
}
public static void main(String[] args) {
SyncItemSample app = new SyncItemSample();
app.enterEventDispatcher();
}
public SyncItemSample() {
UserListScreen userListScreen;
//Check to see if the store exists on the BlackBerry.
synchronized (store) {
if (store.getContents() == null) {
//Store does not exist, create it with default values
userList = new UserList();
store.setContents(userList);
store.commit();
} else {
//Store exists, retrieve data from store.
userList = (UserList)store.getContents();
}
}
//Create and push the UserListScreen.
userListScreen = new UserListScreen(userList);
pushScreen(userListScreen);
}}
And here is an implementation of screen:
public final class UserListScreen extends MainScreen {
Vector fLabels = new Vector();
Vector fValues = new Vector();
VerticalFieldManager leftColumn = new VerticalFieldManager();
VerticalFieldManager rightColumn = new VerticalFieldManager();
UserList fList;
public UserListScreen(UserList list) {
super();
fList = list;
//Create a horizontal field manager to hold the two vertical field
//managers to display the names and ages in two columns.
VerticalFieldManager inputManager = new VerticalFieldManager();
HorizontalFieldManager backGround = new HorizontalFieldManager();
//Array of fields to display the names and ages.
LabelField title = new LabelField("User List",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
final TextField fld1 = new TextField(TextField.NO_NEWLINE);
fld1.setLabel("input label");
inputManager.add(fld1);
final TextField fld2 = new TextField(TextField.NO_NEWLINE);
fld2.setLabel("input value");
inputManager.add(fld2);
final ButtonField fld3 = new ButtonField();
fld3.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
fList.getData().put(fld1.getText().trim(), fld2.getText().trim());
refresh();
}
});
fld3.setLabel("add");
inputManager.add(fld3);
add(inputManager);
//Add the column titles and a blank field to create a space.
LabelField leftTitle = new LabelField("label ");
leftColumn.add(leftTitle);
LabelField rightTitle = new LabelField("value");
rightColumn.add(rightTitle);
refresh();
//Add the two vertical columns to the horizontal field manager.
backGround.add(leftColumn);
backGround.add(rightColumn);
//Add the horizontal field manager to the screen.
add(backGround);
}
private void refresh() {
leftColumn.deleteAll();
rightColumn.deleteAll();
fLabels.removeAllElements();
fValues.removeAllElements();
//Populate and add the name and age fields.
Enumeration e = fList.getData().keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String value = (String) fList.getData().get(key);
final LabelField tmp1 = new LabelField(key);
final LabelField tmp2 = new LabelField(value);
leftColumn.add(tmp1);
rightColumn.add(tmp2);
fLabels.addElement(tmp1);
fValues.addElement(tmp2);
}
}
public boolean onClose() {
System.exit(0);
return true;
}}
So as you see it should be very easy...
So all of these I run application, add values to Persistent object and they are added correctly, are stored during device resets and so on...
When I run Desktop Manager and make a Backup it seems that UserList is backed-up, as size of backup grows together with adding new data into persistent store.
But when I run "Wipe device" on my BB 9300 (and all data from Persistent store is cleared as it is expected) and then run Restore from just made backup file - nothing is updated in the Application and persistent store is seems to be empty.
In some examples I have found adding alternate entry point "init" but I can't tune eveything like it is described with my EclipsePlugin
Could you advice me how to store data in backup file and the to retrieve the same data from backup and load it back to the application, or how to log any of events with Desktop Manager?
If someone has experienced the same problem you can try to disconnect the device before wiping it. It is strange but it helped :)

smartgwt - listgrid editing by cell having some problem

I made listgid which can be edited by cell.
For testing I added save button. When I click on save button then listgrid's first record(updated first column value on first row) should be appear on pop up, but its not showing updated value on pop up.
For example in this case there is first listgrid record name->jon, i edited jon to shobhit and then click on save button. After clicking on save button I should get name shobhit but its showing jon which is the old value.
Please have a look on below my code and help me to accomplish this interesting task.
public void onModuleLoad() {
VLayout vLayout = new VLayout(10);
final ListGrid listGrid = new ListGrid();
ListGridField nameField = new ListGridField("name","Name");
nameField.setWidth(100);
nameField.setAlign(Alignment.CENTER);
ListGridField ageField = new ListGridField("age","Age");
ageField.setWidth(100);
ageField.setAlign(Alignment.CENTER);
ListGridField locationField = new ListGridField("location","Location");
locationField.setWidth(100);
locationField.setAlign(Alignment.CENTER);
listGrid.setFields(nameField, ageField, locationField);
listGrid.setDataSource(getDS());
listGrid.setWidth(310);
listGrid.setHeight(224);
listGrid.setAutoFetchData(true);
listGrid.setCanEdit(true);
listGrid.setEditEvent(ListGridEditEvent.CLICK);
listGrid.setEditByCell(true);
vLayout.addMember(listGrid);
IButton saveButton = new IButton("Save");
saveButton.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
ListGridRecord[] record = listGrid.getRecords();
Record r = record[0];
SC.say(r.getAttributeAsString("name"));
}
});
vLayout.addMember(saveButton);
RootPanel.get("gwtContent").add(vLayout);
}
private RestDataSource getDS() {
RestDataSource ds = new RestDataSource();
DataSourceTextField nameField=new DataSourceTextField("name", "Name");
DataSourceIntegerField ageField=new DataSourceIntegerField("age", "Age");
DataSourceTextField locationField=new DataSourceTextField("location", "Location");
ds.setFields(nameField, ageField, locationField);
ds.setDataFormat(DSDataFormat.JSON);
OperationBinding fetchOB = new OperationBinding();
fetchOB.setOperationType(DSOperationType.FETCH);
OperationBinding addOB = new OperationBinding();
addOB.setOperationType(DSOperationType.ADD);
addOB.setDataProtocol(DSProtocol.POSTPARAMS);
OperationBinding updateOB = new OperationBinding();
updateOB.setOperationType(DSOperationType.UPDATE);
updateOB.setDataProtocol(DSProtocol.POSTPARAMS);
OperationBinding removeOB = new OperationBinding();
removeOB.setOperationType(DSOperationType.REMOVE);
removeOB.setDataProtocol(DSProtocol.POSTPARAMS);
ds.setOperationBindings(fetchOB, addOB, updateOB, removeOB);
if (!GWT.isScript()){
ds.setFetchDataURL("data/dataIntegration/json/data-fetch.js");
ds.setJsonRecordXPath("response/data");
}else{
}
return ds;
}
JSON data file:
{
response: {
status: 0,
startRow: 0,
endRow: 4,
totalRows: 5,
data: [
{"name":"Jon", "age":40, "location":"USA"},
{"name":"Tom", "age":30, "location":"USA"},
{"name":"Frank", "age":35, "location":"USA"},
{"name":"Deb", "age":24, "location":"USA"},
{"name":"Leroy", "age":70, "location":"USA"}
]
}
}
Use the addRowEditorExitHandler for listgrid.This will not require a save button.
Once you make changes and click any where outside grid, control will automatically come to addRowEditorExitHandler.
ListGrid listGrid = new ListGrid();
listGrid.setCanEdit(true);
listGrid.setAutoSaveEdits(false);
listGrid.setDataSource(getDS());
listGrid.addRowEditorExitHandler(new RowEditorExitHandler() {
#Override
public void onRowEditorExit(final RowEditorExitEvent event) {
SC.say(event.getNewValues().get("name"));
//event.getNewValues gives a map of unsaved edits in edited row
//This values u can put to a new record and save it
}
});

Blackberry - How to get Field Labels from PIMItem

How can we get Field Labels from PIMItem. The following code is with PIMList
String label = pimList.getAttributeLabel(
blackBerryContact.getAttributes(Contact.TEL, i));
But i have PIMItem. There is a method PIMItem.getPIMList() which returns null for me in the code below. THE API at http://www.blackberry.com/developers/docs/5.0.0api/index.html says "getPIMList()
Gets the PIMList associated with this item." Below is sample code that i am trying to achive -
// Load the address Book and allow the user to select a contact
BlackBerryContactList contactList = (BlackBerryContactList)
PIM.getInstance().openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY);
PIMItem userSelectedContact = contactList.choose();
// Now get the Field labels for contact numbers for userSelectedContact
class Scr extends MainScreen {
Scr() {
}
protected void makeMenu(Menu menu, int instance) {
super.makeMenu(menu, instance);
menu.add(new MenuItem("add label", 1, 1){public void run() {
try {
BlackBerryContactList contactList =
(BlackBerryContactList) PIM.getInstance().openPIMList(
PIM.CONTACT_LIST, PIM.READ_ONLY);
BlackBerryContact contact =
(BlackBerryContact) contactList.choose();
add(new LabelField(getContactInfo(contact)));
} catch (PIMException e) {
e.printStackTrace();
}
}});
}
String getContactInfo(BlackBerryContact c) {
StringBuffer result = new StringBuffer();
result.append("Name: ");
result.append(c.getStringArray(
BlackBerryContact.NAME, 0)[BlackBerryContact.NAME_GIVEN]);
result.append(" ");
result.append(c.getStringArray(
BlackBerryContact.NAME, 0)[BlackBerryContact.NAME_FAMILY]);
result.append("Email: ");
result.append("\n");
result.append(c.getString(
BlackBerryContact.EMAIL, BlackBerryContact.ATTR_NONE));
return result.toString();
}
}
Thanks Max for the response. The returning NULL issue was problem with my code which i have rectified. I was also able to get Labels for Fields, but the loop retrieves only fields that the Contact has on his card.
I am looking to get all the 8 labels that Contact.TEL has -
Int maxAllowed = contactList.maxValues(Contact.TEL); // Gives me 8
All the 8 Labels might not be in use in for a user, For e.g a user might have WORK, WORK2, HOME, HOME2 and MOBILE. Others FAX, PAGER and OTHER might not be filled i want to get all the allowed labels and update a given number for the one that is empty.
How can we check and update the following
Contact.ATTR_PAGER, Contact.ATTR_FAX, Contact.ATTR_OTHER
Please let me know if the explanation is not clear, or some more details are required.
BlackBerryContactList contactList = (BlackBerryContactList)
PIM.getInstance().openPIMList(PIM.CONTACT_LIST,PIM.READ_WRITE);
PIMItem pimItem = contactList.choose();
BlackBerryContact blackBerryContact = (BlackBerryContact)pimItem;
PIMList pimList = blackBerryContact.getPIMList();
// To get Labels
int phoneCount = blackBerryContact.countValues(BlackBerryContact.TEL);
String[] phoneNumbers = new String[phoneCount];
String[] labels = new String[phoneCount];
for (int i = 0; i > phoneCount; i++) {
String phoneNumber = blackBerryContact.getString(Contact.TEL, i);
String label = pimList.getAttributeLabel(
blackBerryContact.getAttributes(Contact.TEL, i));
//Add the number and label to the array.
phoneNumbers[i] = phoneNumber;
labels[i] = label + ":" + phoneNumber;
}

Resources