Android Formatting Strings Format a string resource

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

You can add wildcards in string resources and populate them at runtime:

  1. Edit strings.xml

    <string name="my_string">This is %1$s</string>
    
  2. Format string as needed

    String fun = "fun";
    context.getString(R.string.my_string, fun);
    


Got any Android Question?