1

I have an application that has the following variable:

public static final String BUSINESS_NAME = "Blahr Industries";

however that String will change depending on who the application is customized for: (so for example another app might be)

public static final string BUSINESS_NAME = "Blech LTD";

Now I also have a database that houses the same information for each version of the application. When retrieved and subsequently displayed the application will need to put in the BUSINESS_NAME variable at the correct place: (ie)

String contentText = "Yada yada, blah blah, promises promises at _____ and we will all be happy";

where " __" = BUSINESS_NAME

** THE QUESTION **

Is there a way to put a variable marker (paramater?) in the String object that will be recognized by Android upon display and filled in? In other words, is it possible to insert the "contentText" String into a SQLite Database so that when it is returned and displayed it will show the correction Business name amidst the other text?

I've read a bit about SQL parameters but don't understand them properly.

Thank you for any assistance.

1
  • Have you tried String.replace()? Commented Sep 29, 2013 at 19:02

1 Answer 1

3

You could put this in the database

String dbEntry = "Yada yada, blah blah, promises promises at %s and we will all be happy";

and when you retrieve it from the database, format the string like this

String contentText = String.format(dbEntry, BUSINESS_NAME);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.