[Solved] How can i use less than or equal to for a string? [closed]


user_bal is a String data type and hence <= is not preferred. If you sure the value of this variable will be numbers (integer as variable lim is of type int, used for compare) , then try this

 String user_bal = (String) dataSnapshot.child("balance").getValue();
    int userBalance = Integer.parseInt(user_bal);

    if (userBalance  <= lim){
        // do something
    Toast.makeText(PostActivity.this, " NOt enough balance", Toast.LENGTH_LONG).show(); 


    }else{
       // do something
    Toast.makeText(PostActivity.this, user_bal, Toast.LENGTH_LONG).show()

    }

8

solved How can i use less than or equal to for a string? [closed]