Android Context Get getString(Context context, int resId, Map replacement)

Here you can find the source of getString(Context context, int resId, Map replacement)

Description

get String

Declaration

public static final String getString(Context context, int resId,
            Map<String, String> replacement) 

Method Source Code

//package com.java2s;
import java.util.Locale;
import java.util.Map;
import android.content.Context;

public class Main {
    public static final String getString(Context context, int resId,
            Map<String, String> replacement) {
        String s = context.getString(resId);
        s = replaceString(s, replacement);
        return s;
    }/*from   w  w  w . ja  v  a 2  s .co m*/

    public static final String replaceString(String s,
            Map<String, String> replacement) {
        if (s != null && !s.equals("") && replacement != null) {
            for (String key : replacement.keySet()) {
                String actualKey = "\\{" + key.toUpperCase(Locale.US)
                        + "\\}";
                s = s.replaceAll(actualKey, replacement.get(key));
            }
        }
        return s;
    }
}

Related

  1. getVersionName(Context context)
  2. getRawInteger(Context c, int resId)
  3. getBitmapFromAssert(Context thisContext, String name)
  4. getString(Context context, int id)
  5. getStringFromXml(Context context, int resId)
  6. getBoolean(ContentValues alarm, String key)
  7. findOne(Context context, Uri uri)
  8. getCurrentTimeString(Context aContext, long aDate)