It all depends on how the project is being built. Assuming you use eclipse
(and its ant build) the shared resources are supposed (as far as i recall)
to be merged into your package, so they're not really in the context of the
"some.package" rather in "some.other.package" (which is why doing
getResources() in your default context works).
Then, when you try to load it directly, you're actually pointing to a
different resource which happens to have the same address
(R.raw_my_shared_res is just an address).
I'm not sure what goes on with Android Studio/Gradle, but my guess the same
might happen.
On Monday, September 2, 2013 9:45:42 AM UTC+3, Antoine Marques wrote:
>
> 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 [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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.