-1

This is really doing my head in, I have been following these instructions but it won't work. Step three is causing me trouble. I'm note sure exactly what needs to be added where. It says;

"In the onCreate() method of your app instance, save your context (e.g. this) to a static >field named app and create a static method that returns this field, e.g. getApp():"

But I only have this at the top of my main java file:

   protected static final String App = null;

The error I get is on this line, it says "The method getContext() is undefined for the type String":

   String[] items = App.getContext().getResources().getStringArray(testholderint);

I figure the issues is with not following step three, and was wondering what exactly I need to add.

Once I've got this rectified my project is basically finished...

Community
  • 1
  • 1
KRL
  • 223
  • 3
  • 12

1 Answers1

0

I think this line

protected static final String App = null;

shouldn't appear at all. The link you provided tells you to create a subclass of your application, like

public class App extends Application { ... }

In this subclass you should put the onCreate() and getContext() methods indicated in the code provided at that link. After doing so your last line (String[] items...) should work just fine.

user964278
  • 13
  • 1
  • 4
  • Thanks for the tip, I realise one stupid mistake I think I was making. I also deleted the line that you suggested but the program still crashes for no apparent reason. – KRL Sep 27 '11 at 12:22
  • Let's see... I'm concerned with that "testholderint". If, as I think, you're trying to retrieve a "StringArray" resource, you need to refer to it as "R.array.testholderint". But maybe you already did it and stored the value in the "testholderint" variable, so I'm not sure about that. – user964278 Sep 27 '11 at 13:30
  • Anyway, it would help to see the manifest and the App class to check if everything is as it should be. – user964278 Sep 27 '11 at 13:31