I have an EditText which is decimal and I set its length using android:maxLength property in xml:
With your example, why don't you use this method?
XML
10
JAVA
getResources().getInteger(R.integer.quantity_length);