Well, this isn't really the appropriate place to answer system hacking related questions, but basically, you're not running in the context of that package, you're running somewhere else, so you're not storing in that shared preferences.
But beyond that, this is just a horrible design, you're using a shared preferences and then: you encode the component statically, leading to a really kludgey hack depending on your system component, you allow the string to be read by *anyone*, not just your app, which it probably should be, and in reality sharing data to an app should probably be shared by using a new system server and then interfaced with via an AIDL component or something of the like, like *every other* system process, that is the "standard" way. You might be upset, because perhaps this is just a quick hack, but then, that type of question doesn't belong on android-developers, and this is what I think is the "right" way to do it :-). You can see tons of other examples of this kind of thing: inside any *Manager, for example, providing this interface. kris On Mon, Aug 13, 2012 at 10:57 PM, galapogos <[email protected]> wrote: > Thanks, I didn't know of the android-platform group, I've posted my question > there. > > Meanwhile, do you have any idea why I would encounter the above-mentioned > problems with SharedPreferences? > > I've also tried simply creating a file in /mnt/sdcard in the framework with > the intention of the app reading it later, but I was thrown a permission > denied error. I was under the impression that accessing the external sdcard > required no special permissions, but if permissions are necessary, I'm not > even sure where to specify it since I can't seem to find the > AndroidManifest.xml of this particular framework component. > > Thanks again. > > > On Monday, August 13, 2012 10:31:47 PM UTC+8, Kristopher Micinski wrote: >> >> This group is solely for SDK related applications. There is a list of >> groups on the website indicating which might be good for this, >> android-platform, and android-porting, perhaps? >> >> I'm a little weary of sticking this in shared preferences for this, >> but I guess there's nothing inherently horrible about that.. >> >> kris >> >> On Mon, Aug 13, 2012 at 5:28 AM, galapogos <[email protected]> wrote: >> > Where would it belong then? >> > >> > Yes I'm trying to share some data between the framework and the launcher >> > app, and I'm trying to accomplish this via SharedPreferences. The >> > framework >> > will set a variable during user authentication, which will then be read >> > later on by the launcher. I'm having some problems doing this as I get a >> > NameNotFoundException exception in my try-catch block. >> > >> > >> > On Monday, August 13, 2012 4:01:59 PM UTC+8, Kristopher Micinski wrote: >> >> >> >> FYI this *definitely* does not belong on android-developers. >> >> >> >> Additionally, it's sort of unclear what you're asking. You're asking >> >> about the sharing of the shared preferences, correct?... If you're >> >> modifying the system and can't figure, that generally doesn't bode >> >> well.. What are you actually trying to do? Something with >> >> authentication? >> >> >> >> kris >> >> >> >> On Mon, Aug 13, 2012 at 2:59 AM, Sihan Goi <[email protected]> wrote: >> >> > Hi, >> >> > >> >> > Is it possible to share data between the Android framework and an >> >> > app? >> >> > >> >> > I'm modifying the Android framework login component so that a >> >> > variable >> >> > will >> >> > be saved upon login, and then later retrieved by another app. I'm >> >> > trying >> >> > to >> >> > use SharedPreferences, and my code looks like this: >> >> > >> >> > In com.android.internal.policy.impl.PasswordUnlockScreen.java, I have >> >> > the >> >> > following code to write to the SharedPreferences. >> >> > >> >> > SharedPreferences prefs = getContext().getSharedPreferences("mypref", >> >> > Context.MODE_WORLD_READABLE); >> >> > SharedPreferences.Editor editor = prefs.edit(); >> >> > editor.putString("mypref", "my data" >> >> > editor.commit(); >> >> > >> >> > In my other app, I have the following code to read from it. >> >> > >> >> > Context con; >> >> > String data; >> >> > try { >> >> > con = this.createPackageContext("com.android.internal.policy.impl", >> >> > 0); >> >> > SharedPreferences pref = con.getSharedPreferences("mypref", >> >> > Context.MODE_PRIVATE); >> >> > data = pref.getString("mypref", "0") >> >> > } catch (NameNotFoundException e) { >> >> > data = "0"; >> >> > Log.e("No data shared", e.toString()); >> >> > } >> >> > >> >> > When I run the code, I keep getting the NameNotFoundException, as it >> >> > claims >> >> > the application package com.android.internal.policy.impl is not >> >> > found, >> >> > so my >> >> > data is always "0". >> >> > >> >> > How can I share data between these 2 components? >> >> > >> >> > Thanks. >> >> > >> >> > -- >> >> > - Goi Sihan >> >> > [email protected] >> >> > >> >> > -- >> >> > 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 >> > >> > -- >> > 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 > > -- > 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 -- 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

