user1884872
user1884872

Reputation: 197

Where can I find file on Android (DDMS)

I try to write string to file in my class, extends AsyncTask:

protected void onPostExecute(String result) {
            super.onPostExecute(result);
            DataOutputStream out = null;
            try {
                out = new DataOutputStream(openFileOutput("1xdf.xml", Context.MODE_PRIVATE));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            for (int i=0; i<20; i++) {
                try {
                    out.writeUTF(Integer.toString(i));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            try {
                out.close();
                Log.e(DEBUG_TAG, "6x");
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

Where can I finde this file in DDMs? When I try search->file 1xdf.xml, I get

Problems encountered during text search. File 'MainActivity/bin/jarlist.cache' has been skipped, problem while reading: ('Resource is out of sync with the file system: '/MainActivity/bin/jarlist.cache'.'). Resource is out of sync with the file system: '/MainActivity/bin/jarlist.cache'.

Upvotes: 0

Views: 3707

Answers (2)

aspergillusOryzae
aspergillusOryzae

Reputation: 756

In the DDMS perspective in Eclipse, select the 'File Explorer' tab and then open the following path:

data/data/com.your.package.name.here/files/1xdf.xml

Where 'com.your.package.name.here' is the name of your project's package / application name. If you want to move the file to your file system, select the 'Pull a file from the device' button on the top right (looks like a floppy disk with a pink arrow pointing to the left) and select the directory on your computer where you want to save the file.

If you want to manually load a file onto your virtual device, use the button to the right of the one above (that looks like a right facing arrow pointing to a phone).

Upvotes: 1

Matt Clark
Matt Clark

Reputation: 28639

When you use context.openFileOutput(), the files are written into the app's data. To check what this path is, you can call getFilesDir().

Upvotes: 2

Related Questions