I want to know what is the best method to transfer data from Android wear for further analysis. Few options I found were to store data on wear's local database or store data on cloud using google cloud Apis. I need to collect data on wear continuously, transfer and analyze that data for further processing.
1 Answers
You could quite easily store the pertinent information on the internal storage of the device and then retrieve it manually when you plug the device into your computer. Something like the following would be quick and easy:
public static void AppendLog(String filename, String text)
{
File log = new File("sdcard/" + filename);
if (!log.exists())
{
try
{
log.createNewFile();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
BufferedWriter writer = new BufferedWriter(new FileWriter(log, true));
String sLogEntry = Log.Tag(severity) + text;
writer.append(sLogEntry);
writer.newLine();
writer.close();
System.out.println(sLogEntry);
}
This method will create a text file, if one does not already exist, and add the specified information to said text file. Each time you want to add information/data for later retrieval, simply use AppendLog("YOUR_FILENAME.txt", "Information you wish to add")
and the data will automatically be added to the log. Then when you plug in your device to the computer you simply retrieve the text file and the data therein. If you use this, make sure to add the WRITE_EXTERNAL_STORAGE
permission to your manifest file.
If you do not have access to the wear device, you would need to send the data wirelessly. One possible option is to send a simple email with the text file as an attachment. An easy way to do this would be to integrate ACRA (Application Crash Report for Android) into your application. While this is library is mainly used to send information after a crash, you can use the framework to send information anytime you want. ACRA would make it easy to gather information about the device and send it to a specified email address. You could also manually add your text file to the ACRA report by using the ReportField.APPLICATION_LOG
and then specifying:
applicationLogFile = "sdcard/YOUR_FILENAME.txt",
applicationLogFileLines = 1000,
Just make sure that the number you set using applicationLogFileLines
is equal or greater than the number of lines you expect to have in your log/data file. I have attached the links to both the quick start guide for adding ACRA to your project, as well as the advanced user guide that discusses topics like manually sending reports without a crash and adding custom information to said report:

- 5,308
- 3
- 32
- 61
-
Thank you. I want to store sensor data from Android wear continuously for further processing. Can I store it on wear's local database? – Durga Malleswari Dec 28 '14 at 18:24
-
It depends on what exactly you mean when you say "database". The code above will save a text file onto the internal storage of the device. If you plug the Wear device into your computer then you will be able to download and open the text file. – Willis Dec 29 '14 at 20:33