文件名称:Android 文件读写源码
文件大小:47KB
文件格式:RAR
更新时间:2018-12-12 16:41:29
Android 文件读写
public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) this.findViewById(R.id.button); button.setOnClickListener(new ButtonClickListener()); } private final class ButtonClickListener implements View.OnClickListener{ public void onClick(View v) { EditText filenameText = (EditText) findViewById(R.id.filename); EditText contentText = (EditText) findViewById(R.id.filecontent); String filename = filenameText.getText().toString(); String content = contentText.getText().toString(); FileService service = new FileService(getApplicationContext()); try { //判断SDCard是否存在,并且可以读写 if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ service.saveToSDCard(filename, content); Toast.makeText(getApplicationContext(), R.string.success, 1).show(); }else{ Toast.makeText(getApplicationContext(), R.string.sdcarderror, 1).show(); } } catch (Exception e) { Toast.makeText(getApplicationContext(), R.string.fail, 1).show(); e.printStackTrace(); } } } }
【文件预览】:
File
----bin()
--------classes.dex(7KB)
--------cn()
--------resources.ap_(11KB)
--------File.apk(16KB)
----res()
--------drawable-ldpi()
--------drawable-hdpi()
--------values()
--------drawable-mdpi()
--------layout()
----assets()
----default.properties(364B)
----gen()
--------cn()
----src()
--------cn()
----.project(840B)
----.classpath(280B)
----AndroidManifest.xml(1KB)