Android: Referring to a string resource when defining a log name

Posted by spookypeanut on Stack Overflow See other posts from Stack Overflow or by spookypeanut
Published on 2011-01-02T22:46:57Z Indexed on 2011/01/02 22:53 UTC
Read the original article Hit count: 141

Filed under:
|

In my Android app, I want to use a single variable for the log name in multiple files. At the moment, I'm specifying it separately in each file, e.g.

public final String LOG_NAME = "LogName";
Log.d(LOG_NAME, "Logged output);

I've tried this:

public final String LOG_NAME = (String) getText(R.string.app_name_nospaces);

And while this works in generally most of my files, Eclipse complains about one of them:

The method getText(int) is undefined for the type DatabaseManager

I've made sure I'm definitely importing android.content.Context in that file. If I tell it exactly where to find getText:

Multiple markers at this line
- Cannot make a static reference to the non-static method getText(int) from the type Context
- The method getText(int) is undefined for the type DatabaseManager

I'm sure I've committed a glaringly obvious n00b error, but I just can't see it! Thanks for all help: if any other code snippets would help, let me know.

© Stack Overflow or respective owner

Related posts about java

Related posts about android