Example usage for android.content Context getString

List of usage examples for android.content Context getString

Introduction

In this page you can find the example usage for android.content Context getString.

Prototype

@NonNull
public final String getString(@StringRes int resId) 

Source Link

Document

Returns a localized string from the application's package's default string table.

Usage

From source file:com.lillicoder.newsblurry.feeds.FeedRepository.java

/**
 * Gets the application default {@link SharedPreferences}.
 * @return Application default {@link SharedPreferences}.
 *///from   www.  j  a va  2  s  .  co m
private SharedPreferences getSharedPreferences() {
    Context context = this.getContext();

    String appPreferencesName = context.getString(R.string.default_preferencesName);
    return context.getSharedPreferences(appPreferencesName, Context.MODE_PRIVATE);
}

From source file:br.ufc.mdcc.mpos.persistence.ProfileNetworkDao.java

public ProfileNetworkDao(Context con) {
    super(con);

    TABLE_NAME = con.getString(R.string.name_table_netprofile);
}

From source file:com.dngames.mobilewebcam.PhotoSettings.java

private static String getDefaultString(Context c, StringPref sp) {
    if (sp.val().length() == 0 && sp.valId() != 0)
        return c.getString(sp.valId());
    else//from ww  w.  ja  va  2  s  .  co  m
        return sp.val();
}

From source file:com.wms.opensource.shopfast.shopify.Cart.java

public static void writeToJSONFile(Context context) {
    JSONArray jsonArray = new JSONArray();
    for (Item item : items) {
        JSONObject jsonObj = new JSONObject();
        try {/*  w  w  w.ja v  a  2  s . co  m*/
            jsonObj.put("productID", item.getProductID());
            jsonObj.put("productName", item.getProductName());
            jsonObj.put("productImageSrc", item.getProductImageSrc());
            jsonObj.put("variantID", item.getVariantID());
            jsonObj.put("price", item.getPrice());
            jsonObj.put("quantity", item.getQuantity());
            jsonObj.put("option", item.getOption());
            if (item.getOptionName() != null) {
                jsonObj.put("optionName", item.getOptionName());
            }
            jsonArray.put(jsonObj);
        } catch (JSONException e) {

        }
    }
    FileUtil.writeStringToFile(jsonArray.toString(), StorageUtil.getTempDirectory(context),
            context.getString(R.string.cartFileName), context.getString(R.string.charSetName));
}

From source file:com.android.google.demo.result.supplement.BookResultInfoRetriever.java

BookResultInfoRetriever(TextView textView, String isbn, HistoryManager historyManager, Context context) {
    super(textView, historyManager);
    this.isbn = isbn;
    this.source = context.getString(R.string.msg_google_books);
    this.context = context;
}

From source file:fr.cph.chicago.connection.CtaConnect.java

private CtaConnect(@NonNull final Context context) {
    ctaTrainKey = context.getString(R.string.cta_train_key);
    ctaBusKey = context.getString(R.string.cta_bus_key);
}

From source file:com.example.awesomedogs.data.Dog.java

public String getDescription(Context context) {
    if (mDescription <= 0) {
        return "";
    }//w  ww  .  j  a  va 2 s  .  c o m
    return context.getString(mDescription);
}

From source file:com.lillicoder.newsblurry.stories.DownloadStoriesTask.java

@Override
protected List<Story> doInBackground(Integer... params) {
    try {/*from w  w  w .  jav  a  2s .  c om*/
        Context context = this.getContext();

        int feedId = params[0];
        String storiesUrl = String.format(context.getString(R.string.api_storiesUrl), feedId);
        HttpGet storiesGet = new HttpGet(storiesUrl);

        // TODO Add name-value pair parameter for page number
        // int pageNumber = params[1];

        // Pull entity and parse JSON response.
        HttpResponse httpResponse = this.executeWebRequest(storiesGet);
        JSONObject responseJson = this.getJsonFromResponse(httpResponse);

        StoryParser parser = new StoryParser();
        return parser.parseStories(responseJson);
    } catch (IndexOutOfBoundsException e) {
        Log.e(TAG, EXCEPTION_FAILED_TO_PARAMS);
        this.setException(e);
    } catch (ApiRequestException e) {
        Log.e(TAG, EXCEPTION_API_REQUEST_FAILED, e);
        this.setException(e);
    } catch (IOException e) {
        Log.e(TAG, EXCEPTION_FAILED_TO_PARSE_RESPONSE, e);
        this.setException(e);
    } catch (JSONException e) {
        Log.e(TAG, EXCEPTION_UNABLE_TO_CREATE_JSON_FROM_RESPONSE, e);
        this.setException(e);
    }

    return null;
}

From source file:fr.licpro.filebox.constants.FileboxErrorCodesEnum.java

/**
 * Get the error message (human-readable and localized).
 * //from  w w  w. j ava2  s.co  m
 * @return The error message (human-readable and localized).
 */
public String getErrorMessage(Context context) {
    return context.getString(mErrorMessageResId);
}

From source file:com.google.zxing.client.android.result.supplement.BookResultInfoRetriever.java

BookResultInfoRetriever(TextView textView, String isbn, HistoryManager historyManager, Context context) {
    super(textView, historyManager);
    this.isbn = isbn;
    this.source = context.getString(FakeR.getId(context, "string", "msg_google_books"));
    this.context = context;
}