android studio中打開DDMS
內(nèi)部存儲(chǔ)空間位置:
導(dǎo)航欄Tools->"Android"->"Android Device Monitor"->File Explorer->data->data->工程目錄
/***
可能出現(xiàn)DDMS無法連接相應(yīng)設(shè)備的情況,原因是真機(jī)或genymotion的root權(quán)限未打開
這篇博客解釋了原因:
http://blog.csdn.net/arex_efan/article/details/20008001
xda解釋的原因及提供的方法
http://forum.xda-developers.com/showthread.php?t=2528952
可自行在網(wǎng)絡(luò)上查找 genymotion-arm-translation_v1.1壓縮包
直接拖拽到genymotion模擬器頁面進(jìn)行安裝
(寶寶你的百度云里有)
重啟后

**/
activity_main:
Button
android:id="@+id/writBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="保存數(shù)據(jù)"/>
Button
android:id="@+id/readBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="讀取數(shù)據(jù)"/>
TextView
android:id="@+id/show"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
MainActivity.class:
privateEditTextet;
privateTextViewshow;
privateStringfilename="test";
protected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et= (EditText)findViewById(R.id.et);
show=(TextView)findViewById(R.id.show);
findViewById(R.id.writBtn).setOnClickListener(this);
findViewById(R.id.readBtn).setOnClickListener(this);
}
public voidonClick(View v) {
switch(v.getId()) {
caseR.id.writBtn:
try{
FileOutputStream fos =? openFileOutput(filename,Context.MODE_PRIVATE);
OutputStreamWriter osw =newOutputStreamWriter(fos,"UTF-8");
osw.write(et.getText().toString());
osw.flush();
fos.flush();
osw.close();
fos.close();
Toast.makeText(getApplicationContext(),"寫入完成",Toast.LENGTH_LONG).show();
}catch(FileNotFoundException e) {
e.printStackTrace();
}catch(UnsupportedEncodingException e) {
e.printStackTrace();
}catch(IOException e) {
e.printStackTrace();
}
break;
/***
* 注意關(guān)閉順序,先打開的后關(guān)閉
* fis.available 文件長(zhǎng)度
*/
caseR.id.readBtn:
try{
FileInputStream fis = openFileInput(filename);
InputStreamReader iis =newInputStreamReader(fis,"UTF-8");
charinput[] =new char[fis.available()];
iis.read(input);
iis.close();
fis.close();
String readed =newString(input);
show.setText(readed);
}catch(FileNotFoundException e) {
e.printStackTrace();
}catch(IOException e) {
e.printStackTrace();
}break;default:break;}}


