I am struggling to find the "Context" value in call this function like
SetFile("Name", ???, 1, "Some text here")
I have looked here https://developer.android.com/reference/android/content/Context but there seems to be a lot of possibilities and not clear to me which one I should use and how. I have no idea what to fill in the "???" place, can anybody help me out on this?
public void SetFile(string BroadCastName, Context Context, long? DirectoryId, string BaseContent)
{
if (!BroadCastName.Contains(".enc"))
BroadCastName = BroadCastName + ".enc";
if (DirectoryId == null)
DirectoryId = 2;
var File = Directories.Where(x => x.Id == DirectoryId).FirstOrDefault().File;
var Path = Directories.Where(x => x.Id == DirectoryId).FirstOrDefault().Path;
File FilesDir = new File(Path, "SDDnode");
FilesDir.Mkdir();
if (bool.Equals(FilesDir.CanWrite(), true)) {
File newFile = new File(FilesDir, BroadCastName);
try
{
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(Context.OpenFileOutput(BroadCastName, FileCreationMode.Private));
outputStreamWriter.Write(BaseContent);
outputStreamWriter.Flush();
outputStreamWriter.Close();
}
catch (IOException e)
{
#region
ledger._base.Errors.Add(new Error {
Message = "Something went wrong in generate file in Android",
Process = "sddnode_android.Base._system",
Sys_Message = e.Message,
Line = 115,
Priority = 1
});
#endregion
}
OutputStream os;
try
{
os = new FileOutputStream(newFile);
//target.compress(CompressFormat.PNG, 100, os);
os.Flush();
os.Close();
}
catch (FileNotFoundException e)
{
e.PrintStackTrace();
}
catch (IOException e)
{
e.PrintStackTrace();
}
}