I figured out the right answer.  In the Eclipse environment, the res/
values folder (unlike the other folders in res/) can have your own
arbitrary files in it.  I created a file called keys.xml, with
<string> elements.  The resources in it, though, are available under
R.string, *not* R.keys.

I git ignore'd res/values/keys.xml, created a keys.xml.example file
and put it in the root of my repo (can't put it in res/values, causes
project errors), and added an instruction to the README to copy and
rename keys.xml.example, and to fill in one's own values.

-- Eric

On Sep 10, 12:05 pm, Eric Mill <[email protected]> wrote:
> I'm not using Ant, and I'm not familiar with it at all.  I'm using the
> regular Eclipse + SDK approach, and I'd like to stick with that.  This
> API key also isn't used in a MapView (it's not for the Google Maps
> API), so I need a general sort of solution.
>
> Isn't there any way, using the Eclipse Android Toolkit, to make some
> sort of keys.xml file and have it available in like, R.keys or the
> like?  It doesn't have to be that, either - as long as I can have all
> of the private strings in their own file, it works for me. I could
> just include a completely flat file and have the app read it in
> manually during operation, but that seems like the wrong way to do it.
>
> -- Eric
>
> On Sep 9, 4:09 pm, Mark Murphy <[email protected]> wrote:
>
> > Eric Mill wrote:
> > > In my app, I'm taking advantage of a web-based API (the Sunlight Labs
> > > API) that requires an API Key.  The project is also open source,
> > > hosted on Github. I want to avoid committing my API key into the
> > > codebase.
>
> > > I'd be fine with creating some other .xml file of special string
> > > values, and git-ignoring that file (while providing a .xml.example
> > > file to copy into its place), but I don't know the best way of doing
> > > that with the Android SDK.
>
> > > Any suggestions?
>
> > Total brainstorm, never tried this, your kilometerage may vary, etc. It
> > also assumes you're using Ant...
>
> > Step #1: Put the layout file containing the MapView element that needs
> > the API key somewhere other than res/layout/ (e.g., make a
> > layout-template/ directory and put it there).
>
> > Step #2: Create an Ant target that reads in a property file and uses
> > <copy> and <replaceregexp> tasks to "paste" the API key out of the
> > property file into a copy of the layout you make in the proper spot
> > (e.g., copy from layout-template/ to res/layout/ and then paste in the key).
>
> > Step #3: git-ignore the post-API-key edition of the layout file and your
> > property file.
>
> > Step #4: Possibly have your Ant target turn around and call some other
> > target (e.g., the debug target).
>
> > Side benefit of this: you can have two targets and two property files,
> > one for debug and one for production.
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> > _The Busy Coders' Guide to *Advanced* Android Development_ In Print!
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to