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 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/c2f4140c-8dcd-4fc1-bfb5-00cbed7b01b6n%40googlegroups.com.