Android数据存取之file (文件存取操作)(2)

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class FileSaveReadActivity extends Activity {
    private EditText filenameText;
    private EditText contentText;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        filenameText = (EditText) this.findViewById(R.id.filename);
        contentText = (EditText) this.findViewById(R.id.content);
        Button saveButton = (Button) this.findViewById(R.id.save);
        Button readButton = (Button) this.findViewById(R.id.read);
       
        /*saveButton.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                String content = contentText.getText().toString();
                String filename = filenameText.getText().toString();
                String sendResult = "发送成功!";
                OutputStream outputStream;
                try {
                    outputStream = FileSaveReadActivity.this.openFileOutput(filename, MODE_APPEND);
                    FileService.save(outputStream, content);
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    sendResult = "发送失败";
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    sendResult = "发送失败";
                }
                Toast.makeText(FileSaveReadActivity.this, sendResult, Toast.LENGTH_LONG).show();
            }
        });*/
       
        saveButton.setOnClickListener(onClickListener);
        readButton.setOnClickListener(onClickListener);
    }
    private View.OnClickListener onClickListener = new View.OnClickListener(){

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwsggy.html