Logging to a file on Android -


Text after "

There is no way to recover log messages from an Android handset.

I'm building an application that uses the GPS of my HTC Hero I can run and debug applications in Eclipse but it is not a good use of GPS, sat at my desk.

I have the fire when I'm running around, I have an intermittent exception. Am no way can I make these exceptions output at Log.x ( "") on the SD card or output calls in a text file so that I can see that the exception is.

Edit: Solution

Here is the code that I went to ...

  Thread CurrentThread () SetUncaughtExceptionHandler (new Thread.UncaughtExceptionHandler () {@Override public void uncaughtException (thread, propellant ex) {PrintWriter pw ;. try {pw = new PrintWriter (new FileWriter (Environment.getExternalStorageDirectory () + '/ rt. log ", true)); ex.printStackTrace (PW); pw.flush (); pw.close ();} catch (IOException e) {e.printStackTrace ();}}});  

I line to wrap

  pw = new PrintWriter (new FileWriter (Environment.getExternalStorageDirectory () + '/ rt.log ", truth) );  

In an attempt / catch because the eclipse will not let me compile the app. It is telling

  unused exception of Sawyer with IOException 1 Quick try to fix / hold  

So I did and All this works which is fine by me but it makes me wonder what about eclipse ...

You can use to catch exceptions.

The writing card in the SD card is as simple as retrieving the directory.

  file f = new file Environment.getExternalStorageDirectory (), file name);  

You will need to allow the right app to write an SD card to this by adding this to your manifest:

  Lt; Uses-permission Android: name = "android.permission.WRITE_EXTERNAL_STORAGE" />  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -