I've written some functions for making/editing the files and they worked fine. However, I needed to use these function in many activities, so I've found the guide on how to globalize functions, and somehow did it. But after I put my functions in the separate class, they stopped working. My logcat is not working, so I can't trycatch it, but even if I could, I don't think it would help me.
Here is part of MainActivity.java:
MyHelper myHelp = new MyHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myHelp.synchronizedb("filename");
}
Here is part of MyHelper.java:
public class MyHelper extends ActionBarActivity {
Context mContext;
public MyHelper(Context context){
this.mContext = context;
}
public void writeFile(String fname, String fcontent) {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(openFileOutput(fname, MODE_APPEND)));
bw.write(fcontent);
bw.close();
}
public void synchronizedb(String filename) {
writeFile(filename, "blabla");
}
}
0 comments:
Post a Comment