LOL. Solved it. I just extend the window of name column in file explorer. Now i know why the names are cut.
Can't find saved file in data/data/package name
Question
I'm saving a hello.txt file with strings inside. But I cant find it in DDMS>selecting my package name in devices>File Explorer>data>data>package name.
Even my package name is cut. My package name is bla.Test9 but it only shows bla. Also under data/data it shows a lot of con folder, jps, and bla folder. Tried to ipen bla folder but I can't find the hello.txt inside
public void save(View v) {
TextView dat = (TextView) findViewById(R.id.textView1);
TextView gdat = (TextView) findViewById(R.id.textView2);
TextView name = (TextView) findViewById(R.id.textView3);
EditText gname = (EditText) findViewById(R.id.editText1);
String s1, s2, s3, s4;
s1 = dat.getText().toString();
s2 = gdat.getText().toString();
s3 = name.getText().toString();
s4 = gname.getText().toString();
FileOutputStream fos = null;
try {
file = getFilesDir();
fos = openFileOutput("hello.txt", Context.MODE_PRIVATE);
fos.write(s1.getBytes());
fos.write(s2.getBytes());
fos.write(s3.getBytes());
fos.write(s4.getBytes());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
EDIT: I'm using an emulator not a device.
Solution 2
OTHER TIPS
try it code
- add permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
in your code snippet
fos.write(s4.getBytes());
fos.flush();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow