Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid in Eclipse - Invoke File Writer class in Background
    primarykey
    data
    text
    <p>When I click the button (btnPrintTardy) I need to generate a .txt file of whatever i have entered into a txtbox (editText1).</p> <p>This is my File Writer java class.</p> <pre><code>import android.app.Activity; import java.io.*; import android.os.Bundle; import android.view.*; import android.widget.*; public class FileWriter extends Activity { EditText txtData; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); txtData = (EditText) findViewById(R.id.editText1); } public void onClick(View v) { // write in data folder try { File myFile = new File("/data/LatePass/StudentLatePass.txt"); myFile.createNewFile(); FileOutputStream fOut = new FileOutputStream(myFile); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(txtData.getText()); myOutWriter.close(); fOut.close(); Toast.makeText(getBaseContext(), "Finished writing StudentLatePass.txt'", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); } finish(); }; } </code></pre> <p>I am calling this method from my "StudentActivity" however, this is where i am kind of stuck. I want to stay on my current screen activity, but run the filewriter in the background. So how would I call this? </p> <p>I have tried</p> <pre><code> public void UpdateStudenttxtfile(View View) { Intent intent = new Intent(View.getContext(), FileWriter.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } </code></pre> <p>with no luck :(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload