oke i found the solution the
 public void savestring(Integer w, String param) {

                  //String Filenm= "/storage/sdcard0/my_csv_file.csv";
                String Filenm=   "/storage/emulated/0/DCIM/Track.csv";

                     try{


                            com.codename1.io.File  f=new
com.codename1.io.File( Filenm );
                         if ( w==1) {
                            if(f.exists()){
                              f.delete();
                              f.createNewFile();
                          } else {
                               f.createNewFile();

                            } }




    FileWriter fw = new FileWriter( Filenm,true); //the true will append
the new data
    fw.write(param + "\n");//appends the string to the file
    fw.close();   }
      catch (Exception e) {
       android.util.Log.d("failed to save file", e.toString());
      }

    }

Op wo 21 okt. 2020 om 20:42 schreef [email protected] <
[email protected]>:

> there  was a mistake in the code, but  still the string isn't appended.
>
>  public void savestring(Integer w, String param) {
>
>                   //String Filenm= "/storage/sdcard0/my_csv_file.csv";
>                 String Filenm=   "/storage/emulated/0/DCIM/Track.csv";
>
>                      try{
>
>
>                             com.codename1.io.File  f=new
> com.codename1.io.File( Filenm );
>                          if ( w==1) {
>                             if(f.exists()){
>                               f.delete();
>                               f.createNewFile();
>                           } else {
>                                f.createNewFile();
>
>                             } }
>
>
>
>                      boolean append = true;
>           FileOutputStream fOut = new FileOutputStream(Filenm, append );
>         OutputStreamWriter osw = new OutputStreamWriter(fOut);
>
>         osw.write(param);
>         osw.flush();
>         osw.close();    }
>       catch (Exception e) {
>        android.util.Log.d("failed to save file", e.toString());
>       }
>
>     }
>
> Op woensdag 21 oktober 2020 om 19:22:03 UTC+2 schreef [email protected]
> :
>
>> Hi
>> I like to add a string to an existing file in the DCIM  folder. The file
>> with the first line is correctly made, but  the next lines not.
>>
>> Here is the  code
>>
>> native
>> mport java.io.File;
>> import java.io.FileInputStream;
>> import java.io.FileOutputStream;
>> import java.io.FileWriter;
>> import java.io.IOException;
>> import java.io.InputStream;
>> import java.io.OutputStreamWriter;
>> import java.text.ParseException;
>> import android.content.Context;
>>
>>
>> public class SaveposImpl {
>>     public void savestring(Integer w, String param) {
>>
>>                   //String Filenm= "/storage/sdcard0/my_csv_file.csv";
>>                 String Filenm=   "/storage/emulated/0/DCIM/Track.csv";
>>
>>                      try{
>>                             com.codename1.io.File  f=new
>> com.codename1.io.File( Filenm );
>>                          if ( w==1) {
>>                             if(f.exists()){
>>                               f.delete();
>>                               f.createNewFile();
>>                           } else {
>>                                f.createNewFile();
>>
>>                             }
>>
>>
>>
>>                      boolean append = true;
>>           FileOutputStream fOut = new FileOutputStream(Filenm, append );
>>         OutputStreamWriter osw = new OutputStreamWriter(fOut);
>>
>>         osw.write(param);
>>         osw.flush();
>>         osw.close();  }  }
>>       catch (Exception e) {
>>        android.util.Log.d("failed to save file", e.toString());
>>       }
>>
>>     }
>>
>>
>> import com.codename1.system.NativeInterface;
>>
>> /**
>>  *
>>  * @author Administrator
>>  */
>>
>> public interface Savepos extends NativeInterface {
>>     public void savestring(Integer w, String param);
>> }
>>
>>
>>
>>
>> in the application
>>
>>    String param = w + ","+ Latp + ","+ Lonp + "," +  TOGl + "," + speed +
>> "," + acc;
>>
>>                               Display.getInstance().invokeAndBlock(new
>> Runnable() {
>>                                     public void run() {
>>                                      savepos1.savestring( w,param);
>>                                     }
>>                                 });
>>
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "CodenameOne Discussions" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/codenameone-discussions/KblxR5MC_vQ/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/codenameone-discussions/c2f4140c-8dcd-4fc1-bfb5-00cbed7b01b6n%40googlegroups.com
> <https://groups.google.com/d/msgid/codenameone-discussions/c2f4140c-8dcd-4fc1-bfb5-00cbed7b01b6n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/CAFNjMcyrT9jvq_Y9sEU8jQjOG%3DY3dut%2B_WMt9NCzR-JOvwTh6A%40mail.gmail.com.

Reply via email to