If you are correctly writing your instrumentation to be against the app package, then targetContext() returns the context for that package giving you access to all that stuff. That is one of the big points of all that, to allow the instrumentation to run inside of the app, as part of the app, with access to everything about the app.
On Mon, Apr 20, 2009 at 4:59 PM, Richard Cook <[email protected]>wrote: > Suppose I have an application that runs functional testing and needs to > access the shared preferences. The function test extends > InstrumentationTestCase, but getting the shared prefs through the Context() > and targetContext() getters provided by the instrumentation doesn't seem to > let me be over writing the shared prefences values. > > How would I go about doing that? Am I right in using the targetContext to > do that? Because it doesn't seem to be letting me. > > On Sun, Apr 19, 2009 at 6:54 PM, APLY <[email protected]> wrote: > >> >> Hi, >> Thanks a lot. >> I get it! >> >> >> >> >> On Apr 18, 12:58 am, Dianne Hackborn <[email protected]> wrote: >> > Are you talking about two applications as in your title or two >> components as >> > in your text? If the latter, there is no reason to use a >> ContentProvider; >> > just use whatever is easiest since they share the same file system: raw >> > files, data bases, shared preferences. For shared preferences, you want >> to >> > avoid putting lots and lots of data there, since when you make a change >> it >> > is all written out as one flat xml file. >> > >> > On Fri, Apr 17, 2009 at 4:52 AM, [email protected] <[email protected] >> >wrote: >> > >> > >> > >> > >> > >> > >> > >> > > Hi all, >> > > Now I have 2 activities that would simultaneously access one data/ >> > > settings. >> > > However, two kind of solution can be applied after I study from the >> > > Android Developer's Guild. >> > >> > > One is ContentProvider, >> > > The discription in guild is as: >> > > "Content providers store and retrieve data and make it accessible to >> > > all applications. They're the only way to share data across >> > > applications; there's no common storage area that all Android packages >> > > can access." >> > >> > > and another is SharedPreferences, >> > > "To use preferences that are shared across multiple application >> > > components (activities, receivers, services, providers), you can use >> > > the underlying Context.getSharedPreferences() method to retrieve a >> > > preferences object stored under a specific name." >> > >> > > What is the differenet between these 2 ? >> > >> > > Thanks a lot! >> > >> > -- >> > Dianne Hackborn >> > Android framework engineer >> > [email protected] >> > >> > Note: please don't send private questions to me, as I don't have time to >> > provide private support, and so won't reply to such e-mails. All such >> > questions should be posted on public forums, where I and others can see >> and >> > answer them.- Hide quoted text - >> > >> > - Show quoted text - >> >> > > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

