I am decrypting a video before playing it in Android. When I decrypt it I want to store in the Android private folder so other apps and users cannot access it – I ve looked up some code which looks like this
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
I am calling this from a helper class which is not an activity class. How do I do this ? It seems to be expecting a call from an activity. And then how do I play it eventually from the folder?
By instancing your helpers class your constructor should accept Context as an extra argument and save it as a class member.
So in the calling activity you can just pass
thisinto it.Then call
ctx.openFileOutput(FILENAME, Context.MODE_PRIVATE)– assuming you named the class memberctx.