/ The data directory in Android is empty I have installed some applications and I created a file in the / data / map directory Code is also written,
I have these lines in the on-line mode, but I do not see any files after running in the / data directory.
file fileer = getFilesDir (); String filed = file dior. Toasting (); Log.v ("Test", "FILEDIR --->" + filedir); // output I got FILEDIR --- & gt; /data/data/com.android.Test/files string strNewFileName = "test1.txt"; String strFileContents = "My first file creation PRGM"; File new file = new file (file dir, stranfile name); Try {Boolean filestat = newFile.createNewFile (); Logs. V ("Test", "Create File =>" + Filestat); // Create output file & gt; True indicator success FileOutputStream fo = new FileOutputStream (newFile.getAbsolutePath ()); Fo.write (strFileContents.getBytes ()); Fo.close (); } Hold (IOException e) {Log.v ("Test", "Exception upon making");}
On the actual device, you can not see these folders if it is not rooted. See the questions.
If you want to write a file in your app directory, then your code is correct. You can check that you made it the same way - from your application:
file myFile = new file (getFilesDir () + "/test1.txt"); If (myFile.exists ()) {// Good! }
Comments
Post a Comment