I want to use the renameTo method to copy a file into another folder but I don't know the path. I want to put a file into the "DCIM" folder in the internal Storage.
oldFile.renameTo(new File("That is the path name I need" + "/myData.txt"));
Thank you very much!!!
File dcim=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
oldFile.renameTo(new File(dcim, "myData.txt"));
Related
I am facing a situation to calculate the free size of the currently selected primary memory(i.e external or external sdcard).
All i have is the file path in app specific folder like below
"/root/extsdcard/Android/data/com.a.b/files/img0001.jpg";
or
"/root/ext/Android/data/com.a.b/files/img0001.jpg";
How i can get the path "/root/extsdcard/" or "/root/ext/" respectively from above shown paths?
Just mention "/" for root directory e.g. File
File f=new File("/");
String files[]= f.list();
I want to find the path of Assets/Plugins/Android directory.
I have tried string filePath = Application.streamingAssetsPath;
But it gives path like jar:file:///mnt/asec/com.cmpny.pkg-2/pkg.apk!/assets
Goal: I want to check programmatically whether a particular jar (abc.jar) file is is present or not. Kindly help me to find that.
I have placed the jar file here (AppName\Assets\Plugins\Android\abc.jar)
I would appreciate any help.
Thanks.
I have a method in my code which takes path of a folder as an argument. When I am using SD card I can simply give the path, but can I do the same with asset, and if so how? I need to write File f=new File(path) so that I can give f.getabsoultepath() as my argument. so what should be the value of path lets assume this is how my asset folder is orginzed and arc is my folder
Hope the subject line makes it clear.
I want to get hold of the file path of the xml file which i store under the res/xml folder.
I'm aware of the InputStream approach by directly reading using the snippet.
... getResources().getXml(R.raw.testxml);
but my requirement is to just get the path of the stored file for the moment.
Any help appreciated
VATSAG
try as to get full path of file stored in res/raw folder
String fullpath = "android.resource://" +
YOUR_FULL_PACKAGE_NAME +
"/"+R.raw.testxml;
How do i make directories in internal storage?
I tried this:
File file = getFilesDir();
this makes me goes to folder "/data/data/com.mypackages/files/"
Then i want to make a folder again in that directories, let's say i want to make "myfiles" folder in there so it becomes, "/data/data/com.mypackages/files/myfiles/".
Can anyone tell me how?
I also tried this:
File file = getDir("myfiles", MODE_PRIVATE);
It makes the folder, but it was created with "app_", so the directories becomes "/data/data/com.mypackages/app_myfiles". I don't want that because i can't read the folder if it has "app_" in there.
The solution is under your eyes :D
m_applicationDir = new File(this.getFilesDir() + "");
m_picturesDir = new File(m_applicationDir + "/pictures");
With this code, i save in m_applicationDir the dir of the package (in your case the dir saved in file).
Then simply create a sub-directory named pictures.
So m_picturesDir points to:
/data/data/com.mypackages/files/pictures