在Android文件中写入问题

时间:2012-04-23 07:46:06

标签: android

我的问题是我无法写入文件:

我在一个活动中有完全相同的代码,并且在我在另一个文件中使用的一个类中相同,并且它适用于该活动,并且它不适用于该文件.....

try {
                                // open fichero.dat for writing
                                OutputStreamWriter out = new OutputStreamWriter(
                                        context.openFileOutput("fichero.dat", Context.MODE_WORLD_WRITEABLE));
                                // write the contents on mySettings to the file

                                out.append(String.valueOf(linea) + "/" + numero + "\n");
                                // close the file
                                out.close();
                                Toast.makeText(context, "Se ha añadido el favorito", Toast.LENGTH_LONG).show();
                            } catch (java.io.IOException e) {
                                Toast.makeText(context, "No se ha podido añadir el favorito el favorito", Toast.LENGTH_LONG).show();
                            }

这是我使用的代码。也没有关于活动,班上也没有给我一个问题(它没有进入“捕获”。但是,当我打开文件时,没有从课程中写出任何内容,并且从活动中写下了,并且我不知道为什么。

¿任何人都可以帮助我?

感谢。

1 个答案:

答案 0 :(得分:0)