Android using jaudiotagger
<p>I try to use jaudiotagger like this
but it crashes</p>

<p>Main app.java :
    import java.io.File;
    import java.io.IOException;</p>

<pre><code>import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.AudioHeader;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.exceptions.CannotWriteException;
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.tag.FieldDataInvalidException;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.KeyNotFoundException;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.TagException;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

public class App extends Activity {
    /** Called when the activity is first created. */


    private TextView txt1;
    private TextView txt2;
    private TextView txt3;
    private TextView txt4;
    private TextView txt5;
    private TextView txt6;
    private TextView txt7;
    private TextView txt8;
    private TextView txt9;






    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       // try
        //{
        File mp3 = new File("/sdcard/test.mp3");
        AudioFile f = null;
        try {
            f = AudioFileIO.read(mp3);
        } catch (CannotReadException e) {
            // TODO Auto-generated catch block
            txt1.setText(e.toString());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            txt1.setText(e.toString());
        } catch (TagException e) {
            // TODO Auto-generated catch block
            txt1.setText(e.toString());
        } catch (ReadOnlyFileException e) {
            // TODO Auto-generated catch block
            txt1.setText(e.toString());
        } catch (InvalidAudioFrameException e) {
            // TODO Auto-generated catch block
            txt1.setText(e.toString());
        }
        Tag tag = f.getTag();
        AudioHeader AudioHeader = f.getAudioHeader();
        txt1.setText(tag.getFirst(FieldKey.ARTIST));
        txt2.setText(tag.getFirst(FieldKey.ALBUM));
        txt3.setText(tag.getFirst(FieldKey.TITLE));
        txt4.setText(tag.getFirst(FieldKey.COMMENT));
        txt5.setText(tag.getFirst(FieldKey.YEAR));
        txt6.setText(tag.getFirst(FieldKey.TRACK));
        txt7.setText(tag.getFirst(FieldKey.DISC_NO));
        txt8.setText(tag.getFirst(FieldKey.COMPOSER));
        txt9.setText(tag.getFirst(FieldKey.ARTIST_SORT));




        try {
            tag.setField(FieldKey.ARTIST,"Kings of Leon");
        } catch (KeyNotFoundException e) {
            // TODO Auto-generated catch block
            txt1.setText(e.toString());
        } catch (FieldDataInvalidException e) {
            // TODO Auto-generated catch block
            txt1.setText(e.toString());
        }
        try {
            AudioFileIO.write(f);
        } catch (CannotWriteException e) {
            txt1.setText(e.toString());
        }
       /* }
        catch(Exception x)
        {
            txt1.setText(x.toString());
        }
        */




    }
}
</code></pre>

<p>Logcat :</p>

<blockquote>
  <p>02-22 21:12:22.546: E/AndroidRuntime(19738): FATAL EXCEPTION: main
  02-22 21:12:22.546: E/AndroidRuntime(19738):
  java.lang.RuntimeException: Unable to start activity
  ComponentInfo{com.mp3.tag.editor.alexander.fuchs/com.mp3.tag.editor.alexander.fuchs.App}:
  java.lang.NullPointerException 02-22 21:12:22.546:
  E/AndroidRuntime(19738):  at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
  02-22 21:12:22.546: E/AndroidRuntime(19738):  at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
  02-22 21:12:22.546: E/AndroidRuntime(19738):  at
  android.app.ActivityThread.access$1500(ActivityThread.java:117) 02-22
  21:12:22.546: E/AndroidRuntime(19738):    at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
  02-22 21:12:22.546: E/AndroidRuntime(19738):  at
  android.os.Handler.dispatchMessage(Handler.java:99) 02-22
  21:12:22.546: E/AndroidRuntime(19738):    at
  android.os.Looper.loop(Looper.java:130) 02-22 21:12:22.546:
  E/AndroidRuntime(19738):  at
  android.app.ActivityThread.main(ActivityThread.java:3691) 02-22
  21:12:22.546: E/AndroidRuntime(19738):    at
  java.lang.reflect.Method.invokeNative(Native Method) 02-22
  21:12:22.546: E/AndroidRuntime(19738):    at
  java.lang.reflect.Method.invoke(Method.java:507) 02-22 21:12:22.546:
  E/AndroidRuntime(19738):  at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
  02-22 21:12:22.546: E/AndroidRuntime(19738):  at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 02-22
  21:12:22.546: E/AndroidRuntime(19738):    at
  dalvik.system.NativeStart.main(Native Method) 02-22 21:12:22.546:
  E/AndroidRuntime(19738): Caused by: java.lang.NullPointerException
  02-22 21:12:22.546: E/AndroidRuntime(19738):  at
  com.mp3.tag.editor.alexander.fuchs.App.onCreate(App.java:72) 02-22
  21:12:22.546: E/AndroidRuntime(19738):    at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  02-22 21:12:22.546: E/AndroidRuntime(19738):  at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
  02-22 21:12:22.546: E/AndroidRuntime(19738):  ... 11 more</p>
</blockquote>
