I created a simple file write/read app in Eclipse and have successfully tested that it could read what it wrote. The structure is fairly simple. I use FileOutputStream to write a samplefile.txt using openFileOutput and a FileInputStream using openFileInput to read it back. The only minor thing is that I don't know where is the file on my physical hard drive? Can anybody point me to where I could find the file in Windows?
If you dont give a absolute path the file will be creataed in aplication directory.
This is /data/data/packge-name-of-your-app/
e.g:
/data/data/com.example.test/
See more http://developer.android.com/training/basics/data-storage/files.html
Go to DDMS perspective, select the emulator which you are using, go to package explorer tag ,then you will get a list of folders hierarchy.
Go to /data/data/
Now you will see a list of packages installed, search for the package name of your app and expand it.
Here you will see the files which your application created when it was running.
P.S : You cannot find this file on the physical drive of your computer,because it is present in the storage of the emulated android virtual device. This storage cannot be directly accessed by you.
Related
My Android-APP creates text files that have to be read by other apps.
I originally chose the following directory, which no longer works:
Environment.getExternalStoragePublicDirectory((Environment.DIRECTORY_DOCUMENTS))
Right now I'm trying the directory:
getFilesDir()
The problem here is that no other app can access this folder.
I'm puzzled as I simply don't know which directory I can use for an exchange between apps.
I have some files you can say a trained model that I need to get their path in my activity class.
I want to use getFilesDir()but it return "data/user/0/com.example.abc/files/".
I just don't know which folder or directory I have to paste my files exactly in order to be in this path so that these file can be get through getFilesDir().
This is the folder on your device
You can find it by opening "Device File Explorer" (this is a collapsed tab in the bottom right of your Android Studio - written vertically on the right edge, bottom)
There you open the folders data/data/com.yourpackage.name/files
Upload your files to this folder and your app can pick them up.
Hope this helps.
Use this way only to test things. For a production scenario you need to package your files in the project, like in the raw or assets folders of your app's resources, so they are contained in the .apk or .aab app bundle.
You can not access this folder via Windows Explorer. The Device must be in developer mode and adb must be running, so you can only access it through android studio or adb command shell. Keep that in mind.
I am developing a mobile application by using Lucene. I have a folder which includes index files. In the application, I want to use these index files for searching. Lucene Library expects path of this folder to read. I placed this folder in the assets folder. But I can't get this folder's path. I checked Android Storage Documentation. But I could not find any solution to add existing folder to external storage. If I would add them to external storage, I can get the path with getExternalFilesDir(). I am working by using emulator.
Directory dir = FSDirectory.open(Paths.get("path of index folder"));
IndexReader reader = DirectoryReader.open(dir);
searcher = new IndexSearcher(reader);
Above code section works well in a Java SE application since I can give the path of folder directly. But In android I am working by using emulator. How can give path of index folder in android? Where should I place this folder to reach in the application?
You put them into the folder into your assets, then copy the assets to the file system on first run. Then you can pass the location you wrote them to to Lucene.
Fair warning: I tried to use Lucene and couldn't a year ago, because it was using IO functions that weren't ported to Android. Now that Java 1.8 exists on Android maybe they have been, but if not you're going to have additional problems to solve.
I have a file on an SD card that is a .txt file that my GUI needs to read the problem is that the GUI will be used on different computers and both on mac and windows OS. the .txt file is rather unique so wont be found on any other drive.
is there a way to scan every drive except C drive(to speed things up as i know it wont be there) to find the file so i can load it into my file reader?
thanks for any help?
You can use java.io.File.listRoots() to see the available drives.
You can use a recursive call through the entire file system: You can use the following methods of java.io.File:
listRoots() : list the root files (In Windows it's the drives, on Mac OS X and linux it's '/').
listFiles() : list the enclosing files of a directory
To recursively search for file check the following link
Search directories recursively for file in java
I have a file on linux ubuntu server hosted with path name /home/kishor/project/detail/.
When I made a web app in window to upload and download file from specified location i used path "c:\kishor\projects\detail\" for saving in window.
For my surprise when i used window file path name in my server i am still able to get files and upload them, i.e, "c:\kishor\projects\detail\".
Can anyone explain why it is working (as window and linux both use different file path pattern).
I've seen this work too. What linux does is create a file whose name is literally c:\kishor\projects\detail\
If you say, you can "upload" files... perhaps there is now a new folder structure.
Some months ago i saw a similar thing: Under /home/webadmin was an new structure "/c:/Users/...."