android - MediaScannerConnection doesn't work -


public void onclick(view v) {     // writing data file     filewriter fw;     try {         fw = new filewriter(environment.getexternalstoragedirectory()+"/datalog.csv", true);          bufferedwriter br = new bufferedwriter(fw);         br.append(formatteddate + string.valueof(location.getlatitude()) +                  ";" + string.valueof(location.getlongitude()) +                  ";" + string.valueof(location.getspeed()) +                  ";" + string.valueof(location.getbearing()) +                  ";" + string.valueof(location.getaltitude()) +                  ";" + string.valueof(location.getaccuracy()));         br.append("\r\n");         br.close();         fw.close();          // mediascanner scans file          mediascannerconnection.scanfile(mainactivity.this, new string[] {fw.tostring()} , null, new mediascannerconnection.onscancompletedlistener() {                  @override                 public void onscancompleted(string path, uri uri) {                 toast t = toast.maketext(mainactivity.this, "scan comlete", toast.length_long);                 t.show();                 }                 } );     } catch (ioexception e) {         e.printstacktrace();     } } 

i tried code write data datalog.csv file in sd root. code creates file data cannot see file in windows when browsing sdcard. saw this video , followed instructions not working me. maybe fw variable not define file?

file csv = new file (environment.getexternalstoragedirectory(), "datalog.csv");                      mediascannerconnection.scanfile(                             mainactivity.this,                            new string[] {csv.getabsolutepath()},                             null, null); 

i tried advice still doing nothing.

tostring() on filewriter not return path file, assuming does, in second parameter pass scanfile().


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -