Sunday, September 1, 2013

[android-developers] Read raw resource from library project using Context.createPackageContext()

I'm sharing resources between projects via a library project. Here's the structure :

MyLibProject  `-- res     `-- raw        `-- my_shared_res  `-- AndroidManifest.xml     `-- Shared user id -> my.shared.user.id     `-- Package        -> some.package      MyProject  `-- AndroidManifest.xml     `-- Shared user id -> my.shared.user.id     `-- Package        -> some.other.package


Inside the Activity of MyProject I want to access R.raw.My_shared_res, but then I noticed the following :

  • getResources().openRawResource(R.raw.my_shared_res) -> returns the correct content of the file while
  • Context c = createPackageContext("some.package", Context.CONTEXT_INCLUDE_CODE & Context.CONTEXT_IGNORE_SECURITY); c.getResources().openRawResource(R.raw.my_shared_res); -> returns a different content, I presumed ciphered.


Can someone explain why this happens ?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate