Where are Android Emulator Images Stored? - android

On the emulator, I downloaded an image from Google. I can find the image on the emulator, but I have no idea what the file location of the image is. To debug my app I need to know where that image is. How can I get the full path of the image?

From the AVD documentation:
By default, the android tool creates the AVD directory inside ~/.android/avd/ (on Linux/Mac), C:\Documents and Settings\<user>\.android\ on Windows XP, and C:\Users\<user>\.android\ on Windows 7 and Vista.
Update (2020-02-22): This wording isn’t on the current documentation page anymore, but the location appears to be the same (C:\Users\<user>\.android\) on Windows 8 and 10.

The system images are downloaded in
[ {android_version_home_dir}/sdk/system-images/{android-version-number}/system.img> ]
and the avd are created in C:\Users\.android\avd\ (windows) or ~/.android/avd/ (linux/mac)

Not obvious thing in official documentation

This here seems to work for me:
String path = Environment.getExternalStorageDirectory().getPath();
String myJpgPath = path + "/Download/dog-best-friend-1.jpg";

If your image is stored on your emulator then you can find that image using file Explore
First Start your Emulator then:
Open your File Explorer and go to mnt/sdcard/Download you will find your image here if its downloaded.
To open file explore in Eclipse : window/show view/other/File Explore

To find the exact path open the emulator go to Photos then click on a photo (if there is any) then click on i (for info). There you can see the exact path on your device.To access these files dynamicly try:
String path = Environment.getExternalStorageDirectory().getPath();
String pathPhotos = path2 +"/Download";
File[] fileArr = new File(pathPhotos).listFiles();
for(int i = 0; i < fileArr.length; i++) {
Log.d("fileName12", " " + fileArr[i].getPath());
}
In case listFiles returns null you have to add:
uses-permission *android:name="android.permission.READ_EXTERNAL_STORAGE" />
And change the settings on the Emulator -> settings -> Apps -> App Permissions -> storage -> your app name -> switch on

In Windows ---> C:\Documents and Settings<user>.android\

On windows:-> C:\Users\yourUser\Documents\AndroidStudio\DeviceExplorer\Pixel_2_API_30 [emulator-5554]\data\data\com.yourpackage\files
After the emulator name, you can choose the path in your code.

Related

Is it possible to allocate these folders in another place?

I am installing Android Studio and I have by default the path C:\Users\Administrator\AppData\Local\Android\sdk to set my SDK. If I choose this option, some folders appeared on the path C:\Users\Administrator.
These folders are:
.android
.AndroidStudio1.3
.oracle_jre_usage
.gradle
To be a little more cleaner I tried to wrap all these folders into another folder but each time I run Android Studio it gives to me the option to configure again the settings. If I configure them again, the folders re-appeared on the path C:\Users\Administrator.
What can I do to wrap these folders into another one or to set another location for them and that the settings will be saved?
EDIT: I prove the solutions on the blog of the answer provided by Rahul Tiwari but I only could get that the folder .android will be in the new folder. The rest folders are at the same location after the changes.
EDIT 2: According to the blog provided by Rahul Tiwari to move the folder .gradle I change the default settings of Android Studio:
File > Other Settings... > Default Settings... > Build, Execution, Deployment > Gradle
Here I have as Service directory path: C:/Users/Administrator/AndroidStudio/.gradle
But the folder .gradle still appears on the path C:/Users/Administrator.
EDIT 3: Trying to remove the folder .AndroidStudio1.3 I changed these lines:
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.plugins.path=${idea.config.path}/plugins
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.log.path=${idea.system.path}/log
to these:
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.plugins.path=${C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/config}/plugins
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.log.path=${C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/system}/log
but I also couldn't move the folder.
EDIT 4: This is the blog that I mention before (Thank you very much Rahul Tiwari). I post it here because his answer was deleted.
Thanks in advance!
Finally, I got the solution to move three of the folders that I put above. I think it could be interesting to put here the problems that I faced and the changes that I made to solve them.
I'm going to investigate about the last folder, .oracle_jre_usage, and I will complete this answer if I got a solution for it. Look that I complete the solution for .gradle folder.
To move .android folder
Really, following the steps of the blog that Rahul Tiwari provided, this folder could been moved. Nevertheless I'm going to put here all the process:
You have to move your .android folder, after closing Android Studio (if you have it running), to the folder in which you want that it will be stored, in my case, C:\Users\Administrator\AndroidStudio.
BEWARE WITH THE SPACES IN THE NAME OF THE NEW FOLDER, IT COULD GIVE TO YOU PROBLEMS (AS ME). I mean, Android Studio, New Folder or similars.
If you are on Windows, you can do right-click on My Computer > Properties > Advanced System Settings > Environment Variables and create a new environment variable named ANDROID_SDK_HOME and as value you have to put the new path in which .android folder will be stored. It's the same path in which you have moved the .android folder in the step above.
Click "OK" button to accept your changes.
Re-launch Android Studio and look that the .android folder doesn't appear in the default path.
To move .AndroidStudio1.3 folder
With that folder I had some problems because I didn't noticed some details that were very important. Here the steps that I followed:
First of all, you have to close Android Studio before doing any change.
After, you have to move the folder .AndroidStudio1.3 to the path in which you want that it will be stored.
Next, you have to go to the folder in which Android Studio were installed and open "idea.properties" file and changed the lines where idea.config.path and idea.system.path appeared for the new path in which these folders are going to be located.
They have to be something similar to this:
idea.config.path=C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/config
idea.system.path=C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/system
Here I had three problems so please be careful:
Notice that the paths are with / and not with \ as Windows put by default.
DON'T CHANGE the values of idea.plugins.path and idea.log.path (My EDIT 3). Be sure that you are changing idea.config.path and idea.system.path values.
Uncomment the lines in which idea.config.path and idea.system.path appears. I mean, remove the # that they have at the begining of each line.
The last step, re-launch Android Studio.
Searching and doing some proves I also get the solution to move .gradle folder. The steps are the same as .android folder but I put here all the steps (with the values that changed) to avoid any confusion. Here it is:
To move .gradle folder
You have to move your .gradle folder, after closing Android Studio (if you have it running), to the folder in which you want that it will be stored, in my case, C:\Users\Administrator\AndroidStudio\.gradle.
BEWARE WITH THE SPACES IN THE NAME OF THE NEW FOLDER, IT COULD GIVE TO YOU PROBLEMS (AS ME). I mean, Android Studio, New Folder or similars.
If you are on Windows, you can do right-click on My Computer > Properties > Advanced System Settings > Environment Variables and create a new environment variable named GRADLE_USER_HOME and as value you have to put the new path in which .gradle folder will be stored. It's the same path in which you have moved the .gradle folder in the step above.
Click "OK" button to accept your changes.
Re-launch Android Studio and look that the .gradle folder doesn't appear in the default path.
How to move data from %UserProfile%
The folders will still remain under %UserProfile%, but not the data.
Move .android
Android Studio is closed
Add Environment Variable
Create "System variable":
Variable name: ANDROID_SDK_HOME
Variable value: D:\Android
Move .AndroidStudio
This is a example with Android Studio version 3.1
Start Android Studio
Help -> Edit Custom Properties...
Click Yes to create file
Edit file with:
idea.config.path=D:/Android/.AndroidStudio3.1/config
idea.system.path=D:/Android/.AndroidStudio3.1/system
The file "idea.properties" is located under:
%UserProfile%/.AndroidStudio3.1/config
Close Android Studio
Delete all under %UserProfile%/.AndroidStudio3.1 except the file "/config/idea.properties"
Optional: Delete older version folders of .AndroidStudio
Don't edit "Android Studio/bin/idea.properties". When updating Android Studio this file is cleared.
Move .gradle
Start Android Studio
File -> Settings... -> Gradle
Change "Service directory path" to:
D:/Android/.gradle
Update Android Studio
Start Android Studio
"Import Studio settings from" is showed
Select: D:/Android/.AndroidStudio3.0/config
I think most of the others answers address the issue, But I found more simple way for windows by adding few environment variables . (Might work for mac as well, I didn't test though)
ANDROID_SDK_ROOT - path to the SDK installation directory
default path - C:\Users\XXXX\AppData\Local\Android\Sdk
Add enviroment variable ANDROID_SDK_ROOT - set value to desired location
Eg: =E:\Android\local\Android\Sdk
For .android folder
default path - C:\Users\XXXX\.android
Add enviroment variable ANDROID_SDK_HOME- set value to desired location
Eg: = E:\Android
For .gradle folder
default path - C:\Users\XXXX\.gradle
Add enviroment variable GRADLE_USER_HOME - set value to desired location
Eg: = E:\Android\.gradle
For .androidstudioXXX
Android Studio-> Help-> Edit Custom Properties
Add below lines
idea.config.path=E:/Android/.AndroidStudio4.0/config
idea.system.path=E:/Android/.AndroidStudio4.0/system
Add environment variable STUDIO_PROPERTIES - set value to desired location
Eg: = E:\Android\idea.properties
Finally don't forget to copy files from the original location to the new location.
Source : https://developer.android.com/studio/command-line/variables
Please see the end of the page to know how to add the environment variable on Windows, Mac or Linux
At least for Android 3.0 the steps in the accepted solution are not enough to be able to run the emulators after moving the .android folder (let's say you moved the folder from c:\Users\<username>\.android to I:\Programs\AppData\.android).
In addition you need to
Copy (or leave) files adbkey and adbkey.pub in old location (i.e. c:\Users\<username>\.android\adbkey, c:\Users\<username>\.android\adbkey.pub)
Replace the old location path string C:\Users\<username>\ in all .INI files found in the new avd location (i.e. in I:\Programs\AppData\.android\avd) with the new location path string I:\Programme\AppData\
Delete all *.qcow2 files from the new avd location (i:\Programme\AppData\.android\avd) which contain the old location path string c:\Users\<username>\. Check Qcow2-files refer to incorrect/nonexistent base-images for an alternative to delete the *.qcow2 files. If you delete the files all data in the emulator is lost, in this case you will get a clean version of Android, like after a hard reset.
To change default .gradle folder using Android Studio 2.2
Open folder of .AndroidStudiox.x (x.x is the version you use) -> config -> options -> gradle.settings.xml file
just right click to open it with wordpad, you should only see 1 option name = serviceDirectoryPath, change the value of that to desired path
remember use / not backward slash \ for folder even in Windows OS
I use junction.exe from Sysinternals to make my Java/Android Studio fully "portable" in Windows:
I have "AndroidStudio" installed in a folder "work".
I have "Java\jdk1.8.0_77_x64" in the same "work".
In the same folder "work" I copied the original ".android", ".AndroidStudio2.2" and ".gradle" folders (from C:\Users\<YourProfile>).
Then in the same parent folder "work" I have copied "junction.exe".
Finally in the same "work" I have a batch __init__.bat with content listed below.
Closed Android Studio and deleted original ".android", ".AndroidStudio2.2" and ".gradle" folders (from C:\Users\<YourProfile>).
Run __init__.bat (as Administrator to set also the JAVA_PATH via setx) to create the new junctions then restart Android Studio. This solution works also after I reimage Windows, just have to remeber to run first the mentioned bat...
PS: When I update java or upgrade Android I have to remeber to tweak the bat with the new revision numbers
Content of __init__.bat:
#echo off
#SET mySrcPath=%cd%
#rem echo "%myPath%"
#rem JAVA_HOME = D:\work\Android\Java\jdk1.8.0_77_x64\
#SET myJavaTarget=Java\jdk1.8.0_77_x64\
#SET myJavaPath=%mySrcPath%\%myJavaTarget%
#if not exist "%myJavaPath%" (
#echo CANNOT FIND myJavaPath = "%myJavaPath%"
#goto _exit_
)
#rem echo myJavaPath = "%myJavaPath%"
#setx JAVA_HOME %myJavaPath%
#SET myTargetPath=%USERPROFILE%
#SET myCopy1=.android
#SET myCopy2=.AndroidStudio2.2
#SET myCopy3=.gradle
#SET mySource1="%mySrcPath%\%myCopy1%"
#SET mySource2="%mySrcPath%\%myCopy2%"
#SET mySource3="%mySrcPath%\%myCopy3%"
#SET myTarget1="%myTargetPath%\%myCopy1%"
#SET myTarget2="%myTargetPath%\%myCopy2%"
#SET myTarget3="%myTargetPath%\%myCopy3%"
#rem echo.
#if not exist %mySource1% (
#echo CANNOT FIND mySource1 = %mySource1%
#goto _exit_
)
#if not exist %mySource2% (
#echo CANNOT FIND mySource2 = %mySource2%
#goto _exit_
)
#if not exist %mySource3% (
#echo CANNOT FIND mySource3 = %mySource3%
#goto _exit_
)
#if not exist %myTarget1% (
#echo creating myTarget1 = %myTarget1% from mySource1 = %mySource1%
#junction.exe %myTarget1% %mySource1%
) else (
#echo myTarget1 = %myTarget1% ALREADY EXISTS !!!!!!
)
#if not exist %myTarget2% (
#echo creating myTarget2 = %myTarget2% from mySource2 = %mySource2%
#junction.exe %myTarget2% %mySource2%
) else (
#echo myTarget2 = %myTarget2% ALREADY EXISTS !!!!!!
)
#if not exist %myTarget3% (
#echo creating myTarget3 = %myTarget3% from mySource3 = %mySource3%
#junction.exe %myTarget3% %mySource3%
) else (
#echo myTarget3 = %myTarget3% ALREADY EXISTS !!!!!!
)
:_exit_
#echo exiting...
#pause

Can't locate application data on Android phone

I have spent many hours trying to find/create files for an app I am writing. When I pull the application directory name I get: /data/data/com.example.android.[myapp]/files. I am using File(getFilesDir():
File fileDir = new File(getFilesDir() + File.separator);
Log.i(TAG, "File directory: "+fileDir);
When I try to find this path I find many application folders here: Android/data/com but no /data/data folder under Android. There are many other application folders there but not mine. I see the same results whether I use Android Files app or Windows Explorer over USB. I've also tried to look using Eclipse DDMS tab. I see a data folder with a (+) to the left but when I click, it does not expand.
I have also tried creating the directory and file manually with Windows explorer and my app still can't find neither the Android/data/com.example... nor the Android/data/data/com.example... paths.
Also puzzling to me is when the app creates the path and file and write to it (using MODE_WORLD_WRITEABLE) I get no exceptions thrown but then I am unable to read it back or see it with either of the tools mentioned above. I have set the manifest permissions to WRITE_INTERNAL_STORAGE and WRITE_INTERNAL_STORAGE for the app.
Obviously, I am making a very basic mistake.
I am on Android 4.1.2 (API 16).
Sincerely,
ScratchingMyHead
To get the path of my application directory, Try this code sample
PackageManager m = getPackageManager();
String s = getPackageName();
try {
PackageInfo p = m.getPackageInfo(s, 0);
s = p.applicationInfo.dataDir;
} catch (NameNotFoundException e) {
Log.w("yourtag", "Error Package name not found ", e);
}
When I try to find this path I find many application folders here: Android/data/com but no /data/data folder under Android.
That is because you are looking on external storage, not internal storage where your files are. Use DDMS on an emulator to examine internal storage.
I've also tried to look using Eclipse DDMS tab. I see a data folder with a (+) to the left but when I click, it does not expand.
That would sound like what you will get when testing on hardware, as neither you nor DDMS have access to the contents of /data on production hardware.

How to add android tools dir to windows 7 path?

I like to quickly start hierarchyviewer. At the moment i use the prompt to go navigate to .... \AppData\local\android\android-sdk\tools\ and then hierarchyviewer
I think i need to add something to windows 7 path, but i don't know what to do exactly.
Any suggestions?
regards
Suppose you have download and install Android SDK, and extract it in some drive. There are two methods to set PATH:
Use command prompt :
set path=%path%;D:\android-sdk-windows\tools;
Another is follow these steps :
My Computer->Property->Advanced->Environment Variables->Edit Path Variable and add “D:\ android-sdk-windows\tools” into the Path Variables.
In your computer properties-advance-environment variables-system variable ,and you find variable "path", add your android/tools path in it.
The operate like add java.exe in you computer path
C:\Users\user\AppData\Local\Android\Sdk\tools\bin
and add it you your Path User variable

Can't locate file context.getDir("data", ...) in Android

I have a db located at
ctx.getApplicationContext().getDir("data", 0) + "/" + "db.db4o";
How can I browse this file with an file manager or via USB? I can't seem to find it :<
Browse with file manager, or USB, what does that mean? You can access the data directory, through a file manager, only if you are on a rooted device or an emulator.
Your application specific file are not directly stored in the data directory, but
data/data/your_package_name
you could create an "asset" folder into your android project and put it there. Before that you can try with this:
InputStream is = getAssets().open("db.db4o");
And convert "is" if is necessary.
Regards

Does anyone know how to create a folder tree in the Eclipse DDMS File Explorer?

I'm trying to create the path "/package name/databases" under the sdcard folder. Anybody got the secret?
Are you using fileobj.mkdir() method from File class? Check if the directory already exist if not exist then create it.Refer
And don't forget about writing permissions for external storage, WRITE_EXTERNAL_STORAGE.
Just select the parent folder and click the small + ("New Folder"). Do this again for the next subfolder.
Creating SD Card
Access to your Android SDK Tools folder and use command “mksdcard” in order to create one.
By default installation on Windows, the Tools folder should be here:
C:\Program Files\Android\android-sdk\tools
Using following syntax to create your desired SD Card
mksdcard [memory size] [output file]
For example, I’d like to create a SD card with 200 MB in memory and put the files in
C:\Personel\AndroidNewbie\SDCard with file named “sdcard_dev.iso“, I do like this:
mksdcard 256M C:\Personel\AndroidNewbie\SDCard\<span class="skimlinks-unlinked">sdcard_dev.iso</span>
Then
Using SD Card
You’ve done creating your desired SD Card, now you need it to be used by Android emulator. Open Eclipse,
access to your project.
On menu Run -> Run Configurations, click on Android Configuration on the left tree menu, click on tab
Target on the right pane. You will see at the bottom: “Additional Emulator Commandline Options” and an
Input/Edit box below:
Just type your input sdcard following syntax
-sdcard [sdcard location]
For example, with the SD Card I’ve created above, I type:
-sdcard C:\Personel\AndroidNewbie\SDCard\<span class="skimlinks-unlinked">sdcard_dev.iso</span>

Categories

Resources