• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to write float values from accelerometer to a file

 
ravindra koranga
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wish to log data accelerometer onto a file in the form of float values. I tried following:



In this code the file is created in the internal storage but there is no data written to it. File is created with zero size. Why does this happen? Please help.

 
Tim Moores
Saloon Keeper
Posts: 3336
61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to flush and/or close the file.
 
ravindra koranga
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try {
            fOut.close();
     } catch (IOException e)
     {

     }
//I tried this after calling save function.It does not help.
 
Norm Radder
Rancher
Posts: 1651
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the catch block that belongs to the try on line 17?   Are exceptions being ignored?
 
ravindra koranga
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I have cropped the code. The try block has on more statement at the last


So full code goes lik this


 
Paul Clapham
Sheriff
Posts: 21978
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have evidence that the save() method is actually called?
 
Norm Radder
Rancher
Posts: 1651
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a Toast to onSensorChanged() to see if it is called.
 
ravindra koranga
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I added a Toast before and after save function. That shows save fun is called. Also onSensorChanged() is called too.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!