Let's assume that I have pre-installed some version of my program on 
Android device (/system/app/MyApp.apk)
It has predefined some strings (e.g. my_preinstalled_application_name)
At some point user updates this application with newer version from market 
without this custom string.
I want my application in cases it is update to system one extract 
this my_preinstalled_application_name and use it.
I've created some code, but stuck how to extract resource from apk:

            final PackageManager pm = context.getPackageManager();
>             ApplicationInfo appInfo = 
> pm.getApplicationInfo(context.getPackageName(), 
> PackageManager.GET_DISABLED_COMPONENTS);
>             if ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) 
> != 0) {
>                 try {
>                     File sysApps = new File("/system/app");
>                     String[] preInstalls = sysApps.list(new 
> FilenameFilter() {
>                         public boolean accept(File dir, String name) {
>                             if (name.endsWith(".apk")) {
>                                 PackageInfo packageArchiveInfo = 
> pm.getPackageArchiveInfo(new File(dir, name).getAbsolutePath(), 0);
>                                 if (packageArchiveInfo != null) {
>                                     if 
> (packageArchiveInfo.packageName.equals(context.getPackageName())) {
>                                         // extract string somehow ??????
>                                         return true;
>                                     }
>                                 }
>                             }
>                             return false;
>                         }
>                     });
>                 } catch (Exception e) {
>                     Log.w(TAG, "Error accessing saved affiliation", e);
>                 }
>             }


pm.getResourcesForApplication throws NullPointerException.

Any thoughts?

-- 
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