Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid error : java.io.filenotfoundexception /proc/net/xt_qtaguid/stats + open failed :ENOENT(no such file or directory )
    primarykey
    data
    text
    <p>i am trying to create android application that allow user to save the file after he enter the file name but the problem is that when user try to save the file an error is displayed that say :</p> <pre><code> Caused by: java.io.FileNotFoundException: /proc/net/xt_qtaguid/stats: open failed: ENOENT (No such file or directory) </code></pre> <p>and then the file it saved as <strong>null.txt</strong></p> <p>how to fix this error ???</p> <h1>SignSactivity.java</h1> <pre><code>package com.devleb.idapp; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import android.app.Activity; import android.app.AlertDialog; import android.app.DatePickerDialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.os.Environment; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class SignSoldgerActivity extends Activity { EditText edit_txt_note; final Context context = this; // attribute for the date picker public String fileName; String userinputResult; Button btndatePicker, btn_save_soldger; TextView txtatePicker; int year, monthofyear, dayofmonth; Calendar cal = Calendar.getInstance(); DateFormat dt = DateFormat.getInstance(); DatePickerDialog.OnDateSetListener dpd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_soldger); edit_txt_note = (EditText) findViewById(R.id.editTxtNote); btndatePicker = (Button) findViewById(R.id.btnDateTimePicker); btndatePicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub new DatePickerDialog(SignSoldgerActivity.this, dpd, cal .get(Calendar.YEAR), cal.get(Calendar.MONTH), cal .get(Calendar.DAY_OF_MONTH)).show(); } }); txtatePicker = (TextView) findViewById(R.id.txtDate); dpd = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // TODO Auto-generated method stub cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, monthOfYear); cal.set(Calendar.DAY_OF_MONTH, dayOfMonth); txtatePicker.setText(new StringBuilder().append(year + "/") .append(monthOfYear + "/").append(dayOfMonth)); } }; btn_save_soldger = (Button) findViewById(R.id.btnSaveSoldger); btn_save_soldger.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // / for creating a dialog LayoutInflater li = LayoutInflater.from(context); View promptsView = li.inflate(R.layout.prompts, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( context); // set prompts.xml to alertdialog builder alertDialogBuilder.setView(promptsView); final EditText userInput = (EditText) promptsView .findViewById(R.id.editTextDialogUserInput); // set dialog message alertDialogBuilder .setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // get user input and set it to result // edit text userinputResult = userInput.getText() .toString(); SimpleDateFormat formatter = new SimpleDateFormat( "yyyy/MM/dd\\HH:mm:ss"); Date now = new Date(); fileName = formatter.format(now) + "/" + userinputResult; saveFile(fileName); txtatePicker.setText(fileName); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } }); } // / for saving the file on the SD public void saveFile(String fileName) { try { String sdPath = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/" + fileName + ".txt"; File myFile = new File(sdPath); myFile.createNewFile(); Toast.makeText(getBaseContext(), "the second step in saving file", Toast.LENGTH_SHORT).show(); FileOutputStream fOut = new FileOutputStream(myFile); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); // append or write myOutWriter.append(edit_txt_note.getText()); myOutWriter.close(); fOut.close(); edit_txt_note.setText(""); Toast.makeText(getBaseContext(), "Done Writing SD" + fileName, Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT) .show(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.sign_soldger, menu); return true; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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