哪里保存文件android app?

时间:2014-08-11 09:35:50

标签: android

我正在学习android,我有代码:

public class SecondNetwork extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        Button go = (Button) findViewById(R.id.do_action);
        go.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                try {
                    URL text = new URL("http://api.flickr.com/services/feeds/photos_public.gne?id=26648248@N04&lang=en-us&format=atom");
                     HttpURLConnection http= (HttpURLConnection) text.openConnection();

                     Log.i("Net", "length = " + http.getContentLength());
                     Log.i("Net", "respCode = " + http.getResponseCode());
                     Log.i("Net", "contentType = "+ http.getContentType());
                     Log.i("Net", "content = "+http.getContent());

                    InputStream isText = http.getInputStream();
                    byte[] bText = new byte[2048];
                    FileOutputStream fos = openFileOutput ("file.out", MODE_PRIVATE);
                    int numAvailable = isText.available();

                    Log.i("Net", "available = " + numAvailable);

                    int readSize = 0;
                    while (readSize != -1) {
                        numAvailable = isText.available();
                        Log.i("Net", "available = " + numAvailable);

                        readSize = isText.read(bText);

                        if (readSize > 0) {
                            fos.write(bText, 0, readSize);
                        }
                        Log.i("Net", "readSize = " + readSize);

                    }

                    isText.close();
                    http.disconnect();
                    fos.close();

                } catch (Exception e) {
                    Log.e("Net", "Error in network call", e);
                }

            }

        });
    }

}

最重要的是:

FileOutputStream fos = openFileOutput ("file.out", MODE_PRIVATE);
fos.write(bText, 0, readSize);
fos.close();

我在哪里可以预览此文件的内容(file.out)?

如果使用系统文件资源管理器,那么我无法找到它。

在DDMS中,eclipse没有搜索引擎。

我在DDMS中尝试(运行和调试):

  

数据>数据>您的应用ID>文件

但第一个文件夹数据为空。

0 个答案:

没有答案