# saveStrings("/sdcard/" + "basher.csv" , text) not working on Android?

**URL:** https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535
**Category:** Processing for Android
**Created:** [May 30, 2018, 12:44pm UTC](https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535 "2018-05-30T12:44:03Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![basher24](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@basher24](https://discourse.processing.org/u/basher24)
#### Post date: [May 30, 2018, 12:44pm UTC](https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535/1 "2018-05-30T12:44:04Z")

</div>

Why saveStrings("/sdcard/" + “basher.csv” , text) not working on android ?

---

<div class="post-metadata">

### Author: ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)
#### Post date: [May 30, 2018, 1:40pm UTC](https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535/2 "2018-05-30T13:40:14Z")

</div>

@basher24===  
put your code & error code.  
What is supposed to be this “/sdcard/” string?

---

<div class="post-metadata">

### Author: ![dan850](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@dan850](https://discourse.processing.org/u/dan850)
#### Post date: [May 31, 2018, 6:32am UTC](https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535/3 "2018-05-31T06:32:52Z")

</div>

@basher24 Is this a Processing for Android issue? Also, can you further explain your issue? please!

---

<div class="post-metadata">

### Author: ![basher24](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@basher24](https://discourse.processing.org/u/basher24)
#### Post date: [May 31, 2018, 11:47am UTC](https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535/4 "2018-05-31T11:47:56Z")

</div>

```auto
void Save_function(int file)
{
   
Table table;  
  
try {
   
  
    table = loadTable("/sdcard/" + str(file) + ".csv"); // trying to load a file from samsung SD CARD 
     
    TableRow newRow = table.addRow();
    
     newRow.setString(0,"LIVE"+file) ;
     newRow.setString(1,Username) ;
     newRow.setString(2,Site) ;
 
    for(int i=3,j=0;j<FieldNumber;i++,j++) {
         
    newRow.setString(i,textlistText[j]);
    
    }
    
    table.addRow(newRow);
    
    saveTable(table, "/sdcard/" + str(file) + ".csv"); 
        
    }
   catch (Exception e) { 
     e.printStackTrace();
     table = new Table();
     saveTable(table, "/sdcard/"+ str(file) + ".csv"); // If the load a failed create new file at samsung SD CARD 
     
   }  
}

```

---

<div class="post-metadata">

### Author: ![basher24](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@basher24](https://discourse.processing.org/u/basher24)
#### Post date: [May 31, 2018, 11:48am UTC](https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535/5 "2018-05-31T11:48:58Z")

</div>

> java.lang.IllegalArgumentException: File /sdcard/1.csv contains a path separator  
> at android.app.ContextImpl.makeFilename(ContextImpl.java:2395)  
> at android.app.ContextImpl.openFileInput(ContextImpl.java:504)  
> at android.content.ContextWrapper.openFileInput(ContextWrapper.java:193)  
> at processing.core.PSurfaceNone.openFileInput(Unknown Source)  
> at processing.core.PApplet.createInputRaw(Unknown Source)  
> at processing.core.PApplet.createInput(Unknown Source)  
> at processing.core.PApplet.loadTable(Unknown Source)  
> at processing.core.PApplet.loadTable(Unknown Source)  
> at processing.test.bb1.bb1.Save\_function(bb1.java:749)  
> at processing.test.bb1.bb1.mousePressed(bb1.java:1410)  
> at processing.core.PApplet.handleMouseEvent(Unknown Source)  
> at processing.core.PApplet.dequeueEvents(Unknown Source)  
> at processing.core.PApplet.handleDraw(Unknown Source)  
> at processing.core.PSurfaceNone.callDraw(Unknown Source)  
> at processing.core.PSurfaceNone$AnimationThread.run(Unknown Source)  
> java.io.FileNotFoundException: /sdcard/1.csv (Permission denied)  
> at java.io.FileOutputStream.open(Native Method)  
> at java.io.FileOutputStream.(FileOutputStream.java:221)  
> at java.io.FileOutputStream.(FileOutputStream.java:169)  
> at processing.core.PApplet.createOutput(Unknown Source)  
> at processing.data.Table.save(Unknown Source)  
> at processing.core.PApplet.saveTable(Unknown Source)  
> at processing.core.PApplet.saveTable(Unknown Source)  
> at processing.test.bb1.bb1.Save\_function(bb1.java:771)  
> at processing.test.bb1.bb1.mousePressed(bb1.java:1410)  
> at processing.core.PApplet.handleMouseEvent(Unknown Source)  
> at processing.core.PApplet.dequeueEvents(Unknown Source)  
> at processing.core.PApplet.handleDraw(Unknown Source)  
> at processing.core.PSurfaceNone.callDraw(Unknown Source)  
> at processing.core.PSurfaceNone$AnimationThread.run(Unknown Source)  
> FATAL EXCEPTION: Animation Thread  
> Process: processing.test.bb1, PID: 599  
> java.lang.NullPointerException: Attempt to invoke virtual method ‘void java.io.OutputStream.flush()’ on a null object reference  
> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:141)  
> at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)  
> at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)  
> at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)  
> at java.io.PrintWriter.flush(PrintWriter.java:320)  
> at processing.data.Table.writeCSV(Unknown Source)  
> at processing.data.Table.save(Unknown Source)  
> at processing.data.Table.save(Unknown Source)  
> at processing.core.PApplet.saveTable(Unknown Source)  
> at processing.core.PApplet.saveTable(Unknown Source)  
> at processing.test.bb1.bb1.Save\_function(bb1.java:771)  
> at processing.test.bb1.bb1.mousePressed(bb1.java:1410)  
> at processing.core.PApplet.handleMouseEvent(Unknown Source)  
> at processing.core.PApplet.dequeueEvents(Unknown Source)  
> at processing.core.PApplet.handleDraw(Unknown Source)  
> at processing.core.PSurfaceNone.callDraw(Unknown Source)  
> at processing.core.PSurfaceNone$AnimationThread.run(Unknown Source)

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [June 3, 2018, 12:11am UTC](https://discourse.processing.org/t/savestrings-sdcard-basher-csv-text-not-working-on-android/535/6 "2018-06-03T00:11:37Z")

</div>

Can you please tell us where did you place this file? Are you planning to modify this file in your code or will it be only used as a resource which is loaded but not modified?

If you are not modifying this file, then you should place the file inside a folder named `data` which must be located inside your sketch folder. Another way to add this file to your sketch is to drag the file from an explore window and drop it in the sketch window. The PDE will create the data folder for you and copy the file to that directory.

If you are loading this file from an external drive, as I can see from your attempt in your code, then you need to have a look at this post [here](https://forum.processing.org/two/discussion/21167/accessing-sd-cards-for-storage). Please don’t forget to enable writing permission to the external storage. To do so, in the PDE in Android mode, go to _Sketch\>\>Permissions_ and then scroll down to almost the end of the list and check the writing to external.

More links related to external storage in Android:

[https://forum.processing.org/two/discussion/18126/load-image-files-from-external-storage-to-pimage/p1](https://forum.processing.org/two/discussion/18126/load-image-files-from-external-storage-to-pimage/p1)[https://forum.processing.org/two/discussion/9893/save-images-in-specific-folders-android#latest](https://forum.processing.org/two/discussion/9893/save-images-in-specific-folders-android#latest)[https://forum.processing.org/two/discussion/comment/77652/#Comment\_77652](https://forum.processing.org/two/discussion/comment/77652/#Comment_77652)

Don’t forget to check the Android documentation as the Android API offers other options that might be suitable to your task:

[https://developer.android.com/guide/topics/data/](https://developer.android.com/guide/topics/data/)  
[https://developer.android.com/training/data-storage/files#WriteExternalStorage](https://developer.android.com/training/data-storage/files#WriteExternalStorage)

Kf
