0

I can create a JSON file in DCIM directory of Glass but the file is not visible when I access it on glass.

Here is the code:

File jsonFile = new File(Environment.getExternalStorageDirectory()
                + File.separator + "DCIM/test/file.json");
//file address    

String json = "{\"id\":1}";
//text to be written on the file

FileWriter fw = new FileWriter(jsonFile);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(json);
bw.close();
fw.close();
//writing the file

I can only access the file in DDMS view in Eclipse.

I have added the following permission:

android.permission.WRITE_EXTERNAL_STORAGE
pt2121
  • 11,720
  • 8
  • 52
  • 69
Euber
  • 33
  • 5
  • Tip. Use the new File(parent, child) constructor so you don't need to use + File.separator – Adam Oct 13 '14 at 07:23
  • Why would you create a JSON file in the Digital Camera IMages (DCIM) folder in the first place? Smells like you need to rethink your architecture. – straya Oct 13 '14 at 11:42

2 Answers2

1

You can view it with DDMS that means the file was created. I think there is no problem with your app.

If you want to open the file, you can pull the file out from your Glass using adb:

adb pull /sdcard/DCIM/test/file.json

And view it with whatever application you want.

Also see http://developer.android.com/tools/help/adb.html

To copy a file or directory (and its sub-directories) from the emulator or device, use

    adb pull <remote> <local>
pt2121
  • 11,720
  • 8
  • 52
  • 69
  • The idea was that the user could load the file manually, using windows exporer or something more friendly. I performed some tests, with windows explorer the user can not see the file created by the application, but if user put the file, the application can load it. – Euber Oct 13 '14 at 17:21
0

Why would you create a JSON file in the Digital Camera IMages (DCIM) folder in the first place? Smells like you need to rethink your architecture.

straya
  • 5,002
  • 1
  • 28
  • 35