regarding the Android Assets manager, is it possible to get a file from the assets without context? I read that I can initialize a File object with "file:///android_assets" kind of path, and then get the file from there, but it says that the file does not exist (Honeycomb).
What is t开发者_运维知识库he general workaround around this issue? There is no any way to get the context on the place I need the files from the assets.
Thanks
To get access to the Context where it's not present you can extend Application class and create the static reference to the Context. This way you can access it from anywhere within the application:
public class MyApp extends Application {
public static Context context;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
}
精彩评论