import java.io.File;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
public class XiaoxiongActivity extends Activity {
/ ** Called when the activity is first created. * /
@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
/ *
new Thread () {public void run () {
file = new File ("/ data / hello.txt");
if (file.isFile ()) {
} Else {
try {
file.createNewFile ();
} Catch (IOException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
}
.}} Start ();
* /
}
@ Override
protected void onResume () {
/ / TODO Auto-generated method stub
runtime = Runtime.getRuntime ();
try {
runtime.exec ("dumpsys cpuinfo> / data / cpuinfo.txt");
} Catch (IOException e1) {
/ / TODO Auto-generated catch block
e1.printStackTrace ();
}
super.onResume ();
}
private Runtime runtime;
private File file;
}
This is all the code, anyone know how else?
Reply:
FileInputStream inputStream = context.openFileInput (fileName);
Reply:
/ I do not write anything to the file, just create an empty. Txt file
Reply:
Into the output stream
Reply:
Wrong path maker to create this path
Reply:
XiaoxiongActivity this is where your java class files
file = new File ("/ data / hello.txt"); then this too and your file directory at the same level, so you can rewrite data / hello.text try
Reply:
Thank you!
The original is a permissions issue
Reply:
I have problems and you like, ask how else ah, Ji Jiji anxious
Reply:
How to resolve permission issues for the landlord?
Reply:
Landlord, I ask how to solve?
Reply:
Add this code
in androidmanifest.xml file
Reply:
The authority to modify a reply
No comments:
Post a Comment