Android: find a file created in AVD - android

My application has a function of creating an xls file. After that I need to access that file manually. Now, the problem is, when i run the app on my device, I am able to locate the directories and my xls file in internal storage.
But when I try to run that in the AVD, I am not able to find the file. I also viewed file explorer but there also, I wasn't able to find my file.
Where does the file exists when created in AVD?
Below is the code :
File myDir = new File(Environment.getExternalStorageDirectory()+ "/PB/automation/mydir/");
myFolder.mkdirs();
File file = new File(myFolder, "demo.xls");
Trust me, there is nothing wrong with the code.
Below is the file explorer view :

Related

How to fix java.io.FileNotFoundException?

I try to access the file I had downloaded from flutter app and save it to external storage. I call the file and use it in java part but it show this error:
java.io.FileNotFoundException: /storage/emulated/0/Android/data/abc.xyz.qwe/files/mobilenet.tflite
I have tried to grant permission before call the file but it still not work (The file is exist, i have checked).
You start the file name with a slash. What directory is the file located in? If the storage folder is not in the root directory (/), then you won't be able to find the file. If storage is in the same place as the java file you're running, you should remove the first /

How to Save files to system files on Android

I want to save file to files system on Android to this path "/efs/wifi/"
I created My file by FileWriter writer =new FileWriter (file,true) i want save this file to path above
For root devices
Another thing how can i copy from sd card to same path above "efs/wifi/" Please help me .
You can use libsupersu to make application for root device.
Add dependency to your gradle file:
compile 'eu.chainfire:libsuperuser:1.0.0.+'
In your code, ask root permission by:
Shell.SU.available();
After your app grant permission from user, you can copy file to anywhere to want.

How to get access to application classes.dex file

I believe that every application can get access to its own files, for example - to classes.dex file.
I wonder how the application get access to its files?
and another question, can I fake this access and get access to another application.?
you can point to the apk file of your application using ApplicationInfo.publicSourceDir
File yourApk = new File(this.getApplicationInfo().publicSourceDir);
//create the destination dir
File tempDir = new File(getFilesDir(), "temp_dir");
//and then unzip the apk to that dir
unzip(yourApk , tempDir);
//now the tempDir will contain all the resources including the dex file and its accessible
this file is a zip file you can decompress that file using this link
How to unzip files programmatically in Android?
so you will have the access to all resources plus the classes.dex
hope this will help

Bad path trying to open file in Android

I'm trying to open a file with this:
document = builder.parse(new File("Data.xml"));
and I'm getting this message:
/Data.xml: open failed: ENOENT (No such file or directory)
and the file is in the root directory of the android project.
You are trying to open a file located in / (in linux this is the root directory of your file system). Instead you should be trying to create a file either on the SDCard or within the local storage directory for your application.
See this for more clarification: http://developer.android.com/guide/topics/data/data-storage.html
Move Data.xml into the assets folder of your project. Then to get a file reference, call getResources().getAssets().openFd( "Data.xml" )
You should probably try using a file input stream constructor for the builder instead, and use openFileInput( String fileName ) to get that, which does only use your app's data directory.
Using persistent storage
openFileInput()

Adobe Air for Android: Where is a xml file after instalation .apk file

An Air app which loading data from an external XML file (cfg.xml). I've published the Android/Air file, included the cfg.xml file in the Android package. Then I've installed on my SD Card(). App's reading xml file - working perfectly. But I need raw access(on my device) to cfg.xml I cannot find this file, checked everywhere(Rooted Phone). Where is it? Is there other solution? I need a file which is easy to read/write.
Use DDMS -> File Explorer and look for you app name in folders like data, ...
Solution:
Use fileStream instead of URLLoader
Change directory to SD Card e.g.
File.userDirectory.resolvePath("YourAppData/cfg.xml")
(No rooted phone needed)

Categories

Resources