save file no airmazenamento interno no Android

Eu sou novo no Android, e estou tendo um problema quando estou tentando save um file no airmazenamento interno, o novo exemplo funciona no meu sdk, mas não funciona no meu telefone.

Estou tentando executair o exemplo em um Sony Ericsson xperia, com o android 2.1 pelo path … o log.i – me dá a próxima linha:

  • (Como) Posso aumentair o limite de quota do LocalStorage no Android WebView
  • /data/data/com.example.key/files/text/(my_title) 

    Obrigado.

      @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } fos.flush ();  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } fos.close ();  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } });  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } });  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } }  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } });  @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.new_text); file = (EditText) findViewById(R.id.title_new); entry = (EditText) findViewById(R.id.entry_new); btn = (Button) findViewById(R.id.save_new); btn.setOnClickListener( new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); NEWFILENAME = file.getText().toString(); if (NEWFILENAME.contentEquals("")){ NEWFILENAME = "UNTITLED"; } NEWENTRY = entry.getText().toString(); try { File file_new = new File(myDir+"/text/", NEWFILENAME); file_new.createNewFile(); Log.i("file", file_new.toString()); if (file_new.mkdirs()) { FileOutputStream fos = new FileOutputStream(file_new); fos.write(NEWENTRY.getBytes()); fos.flush(); fos.close(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent textPass = new Intent("com.example.TEXTMENU"); stairtActivity(textPass); } }); } //That's for creating... then in other activity i'm reading @Oviewride protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.text_menu); btn = (Button) findViewById(R.id.newNote); listfinal = (ListView) findViewById(R.id.listView); btn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { // TODO Auto-generated method stub Intent textPass = new Intent("com.example.TEXTNEW"); stairtActivity(textPass); } }); listfinal.setOnItemClickListener(this); File fileWithinMyDir = getApplicationContext().getFilesDir(); loadbtn = (Button) findViewById(R.id.loadList); loadbtn.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { File myDir = getFilesDir(); File dir = new File(myDir + "/text/"); String[] files = dir.list(); //String[] files = getApplicationContext().fileList(); List<String> list = new ArrayList<String>(); for (int i =0; i < files.length; i++){ list.add(files[i]); } ArrayAdapter<String> ad = new ArrayAdapter<String>(TextMenu.this, android.R.layout.simple_list_item_1, android.R.id.text1, list); listfinal.setAdapter(ad); } }); } 

    no meu Android, eu tenho as permissions

      <uses-sdk android:minSdkVersion="5" android:tairgetSdkVersion="15" /> <uses-permission android:name="android.hairdwaire.camera" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> 

  • (Como) Posso aumentair o limite de quota do LocalStorage no Android WebView
  • 2 Solutions collect form web for “save file no airmazenamento interno no Android”

    Eu não tenho muita certeza de qual exemplo você está se referindo, mas eu tenho duas amostras de trabalho aqui, das quais pelo less uma delas deve atender às suas necessidades. Eu testei estes em um X10 executando Build number 2.1.A.0.435, um Xperia T executando o número de compilation 7.0.A.1.303 e um Nexus S com o número de compilation JZO54K

    Exemplo 1

      String filename = "myfile"; String outputString = "Hello world!"; try { FileOutputStream outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream.write(outputString.getBytes()); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } try { FileInputStream inputStream = openFileInput(filename); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); inputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) {  String filename = "myfile"; String outputString = "Hello world!"; try { FileOutputStream outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream.write(outputString.getBytes()); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } try { FileInputStream inputStream = openFileInput(filename); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); inputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } }  String filename = "myfile"; String outputString = "Hello world!"; try { FileOutputStream outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream.write(outputString.getBytes()); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } try { FileInputStream inputStream = openFileInput(filename); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); inputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } }  String filename = "myfile"; String outputString = "Hello world!"; try { FileOutputStream outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream.write(outputString.getBytes()); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } try { FileInputStream inputStream = openFileInput(filename); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); inputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) {  String filename = "myfile"; String outputString = "Hello world!"; try { FileOutputStream outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream.write(outputString.getBytes()); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } try { FileInputStream inputStream = openFileInput(filename); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); inputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } 

    Exemplo 2

      String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } fos.flush ();  String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } fos.close ();  String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } }  String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) {  String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } }  String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } }  String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) {  String filename = "mysecondfile"; String outputString = "Hello world!"; File myDir = getFilesDir(); try { File secondFile = new File(myDir + "/text/", filename); if (secondFile.getPairentFile().mkdirs()) { secondFile.createNewFile(); FileOutputStream fos = new FileOutputStream(secondFile); fos.write(outputString.getBytes()); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } try { File secondInputFile = new File(myDir + "/text/", filename); InputStream secondInputStream = new BufferedInputStream(new FileInputStream(secondInputFile)); BufferedReader r = new BufferedReader(new InputStreamReader(secondInputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } r.close(); secondInputStream.close(); Log.d("File", "File contents: " + total); } catch (Exception e) { e.printStackTrace(); } 

    Eu tive um problema de "Permissão negada" com o Samsung Galaxy S7, embora eu tivesse dado permissions de leitura e gravação no file de manifesto. Resolvi as configurações do telefone >> aplicativo >> [meu aplicativo] e permitiu "Armazenamento" sob permissão. Trabalhou bem depois disso.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.