how can i create a class and use this piece of code. If i put the code in the fragment class, MODE_WORLD_READABLE cannot be resolved to a variable error is displayed. Only when i add this code to an activity it works.
In general i get a byte array and write it to a file. When this was on the activity class it worked great. When i added it to a fragment class it displays the error above.
MODE_WORLD_READABLE is defined in Context, and Activity is a subclass of Context. But since you move the code out of the Activity, you need to tell the compiler (and Eclipse) where MODE_WORLD_READABLE comes from, so use Context.MODE_WORLD_READABLE instead.