package com.example.diary;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;

public class DiaryLogView extends Activity {
	private EditText logText;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.log_view);
        logText = (EditText)findViewById(R.id.logText);
        FileInputStream fis;
        try {
        	fis = openFileInput(DiaryActivity.LOGFILENAME);
    		FileChannel fc = fis.getChannel();
    		MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
    		String text = Charset.defaultCharset().decode(bb).toString();
    		logText.setText(text);
        }
        catch (IOException ioe) {
    		Log.e("DiaryLogView", ioe.toString());
        }

	}
	

}
