File内部存储
- FileOutPutStream FileInputStream
FileActivity 以及对应的xml文件
package com.example.test0508;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileActivity extends AppCompatActivity {
private EditText mEtName;
private Button mBtnSave,mBtnShow;
private TextView mTvContent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file);
mEtName = findViewById(R.id.edit_file_name);
mBtnSave = findViewById(R.id.btn_file_save);
mBtnShow = findViewById(R.id.btn_file_show);
mTvContent = findViewById(R.id.tv_file_content);
mBtnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
save(mEtName.getText().toString());
}
});
mBtnShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mTvContent.setText(read