Convert XML String to Int with default value - Android XML

Android examples for XML:XML Node

Description

Convert XML String to Int with default value

Demo Code


//package com.java2s;

public class Main {
    public static int toInt(String text, int defaultVal) {
        int value = defaultVal;

        try {//from  w  ww  . j  a va2  s.c om
            value = Integer.parseInt(text.trim());
        } catch (Exception e) {

        }

        return value;
    }
}

Related Tutorials