S
S
Sergey Lerg2014-07-12 03:51:55
Java
Sergey Lerg, 2014-07-12 03:51:55

How to use assets/ directory instead of res/?

There is a JAR library that I need to embed into my application.
The catch is that it comes with its files in res/, and for technical reasons I can't change this directory, but I have full access to assets/.
In res/ there are various pictures of different resolutions, layouts, a font file, a sound file and just localized strings in xml.
The library was easily decompiled and found the following class inside it.

package com.purplebrain.giftiz.sdk.util;
 
import android.content.Context;
import android.content.res.Resources;
 
public class GDKId
{
  public static int getId(String paramString, Context paramContext)
  {
    return paramContext.getResources().getIdentifier(paramString, "id", paramContext.getPackageName());
  }
 
  public static int getString(String paramString, Context paramContext)
  {
    return paramContext.getResources().getIdentifier(paramString, "string", paramContext.getPackageName());
  }
 
  public static int getLayout(String paramString, Context paramContext)
  {
    return paramContext.getResources().getIdentifier(paramString, "layout", paramContext.getPackageName());
  }
 
  public static int getAnim(String paramString, Context paramContext)
  {
    return paramContext.getResources().getIdentifier(paramString, "anim", paramContext.getPackageName());
  }
 
  public static int getRaw(String paramString, Context paramContext)
  {
    return paramContext.getResources().getIdentifier(paramString, "raw", paramContext.getPackageName());
  }
 
  public static int getDrawable(String paramString, Context paramContext)
  {
    return paramContext.getResources().getIdentifier(paramString, "drawable", paramContext.getPackageName());
  }
}

It looks like he is responsible for loading all the resources.
How to modify it so that instead of res/ it uses, say, assets/res/ ?
Or another option is to convert all files to base64 and store as strings right inside .java files. If it's easier, then you can too.
I have never had to deal with Java before.
UPD I realized that this class only returns the ID of the resources, and not the resources themselves, but the question remains, how to do without the res/ directory?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Lerg, 2014-07-17
@Lerg

It turns out this is impossible. But I was still able to solve my problem using apktool.
I unpack the APK, copy additional resources to res/, pack it back.

A
Andrey M, 2014-07-12
@Collosteam

Look here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question