Reference file on Android device that was placed via USB - android

I have an html file that I placed on my Android device via USB (Android File Transfer). Android file transfer doesn't show any paths, so I don't know what directory this file is being placed in. I downloaded a file manager app on the device by ZenUI that suggests the file is in "root/sdcard/theFile.html" but referencing it in an app using "file:///root/sdcard/theFile.html" does not work even if all the appropriate Manifest permissions are in place ("file not found").
I am using a Droid Turbo 2

This is probably device-dependent. On my Nexus 6 is it
file:///storage/emulated/0/Download/file.html
(if you placed your file in Downloads).
If you have an SD-Card inside, maybe just trying emulated/1/... helps, or just download TotalCommander, navigate to the file and look up the properties of the file (Location:) will help you.
Hope that helps.

Related

How to create file on android using xamarin?

I've tried several folders but looks like no file is created.
External read & write permission have been enabled.
The code run without any sign of error. (as given below)
Here is the screenshot of the code inside mainactivity.cs (this is for testing purposes).
I also assume that since this is platform specific, the code must be in android project.
string filename = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, "count1.txt") ;
StreamWriter sw = File.CreateText(filename);
sw.WriteLine("asad ini test");
sw.Close();enter code here
1b. I 'm using Android 6.0 phone, but I can't find such folder /data/user...
(I'm not sure if such folder is targeted special version of Android)
I search both internal /Android/myproject/files/ and found nothing
I search external SDcard /Android/myproject/files/ and still found nothing
(please look at the my android phone folders, i can't even find /data folder
Once, this is accomplished the next step would be how to call this function from the generalproject (non android, non IOS, non UWP project).
Example to write file given in xamarin document.
Where should this code reside? in general project folder ? or, android project folder?
The term "external" used in android is very misleading. It doesn't mean the external removable SD card rather some folders that don't require "root" permission. Therefore, initially I can't find the folder which I save a file into.
Another reason is each phone manufacture uses different name, hence it is very difficult to get an absolute address of an external removable SD Card.
More details is explained in blog_external_removable_SD_Card
You can't write to the removable SD Card
an old post here

AVD SD Card - External File

Im using the latest version of Android Studio and it won't allow me to add and external SD Card made with "mksdcard". In previous versions this was possible but now it just reverts to blank every time I try to add a new SD card.
Anyone face this problem or know how to fix?
One of the issues that the Android forgot to mention is with Android Studio 3.0 when you create AVD you need to now create an image for the SD CARD with the
mksdcard tool to create a FAT32 disk image. After you use this tool then when you are creating the AVD you will see under advanced view the SD CARD area the
External files click that and navigate to where you stored the sdCard.img file you created with mksdcard tool.
Here is a bonus trick USE WITH CAUTION you can tell that emulator that it has the SD CARD ejected by changing this value hw.sdCard=yes in its config.ini file from
yes to no. How to find the config.ini file
Windows Explore find the android/avd/device name open the device name file then
with a FILE EDITOR like Sublime Text make the change to hw.sdCard=no and do a
SAVE AS I suggest you not use MS notepad to do this
I was facing the same problem today and found your question here on SO.
I was able to solve this issue by finding the config.ini file of the AVD itself,
and by editing it manually (e.g. with Notepad). On my Windows 10 machine the file is this one.
C:\Users\peter\.android\avd\Nexus_5_API_25.avd\config.ini
In that file I had to manually edit the value of this property as follows.
sdcard.path=C:\Programs\Android\SD_Card_Image\SD_Card001.img
That seems to make Android Studio to not revert back to a blank external file name.
EDIT:
The weird thing is that even you specify an external file for your SD card image (as opposed to a studio managed SD card), that doesn't mean the AVD is using this exact file which you specified. Seems it uses it just initially (for initialization). Then Android Studio creates a copy of the image file somewhere (inside the AVD folder it seems) and from there on it uses his own copy. That was quite a surprising behavior to me. I even find it buggy. If that's what's intended, then what is the purpose of having the option to specify an external file?
That page does the same to me for "Device Frame" checkbox. It's always unchecked even though it does apply the skin.
So check first whether you can access the SD as you're supposed to.

Cant use fopen in expansion folder on some Android devices

Our game is bigger than 50Mb so we will be using an expansion file. This supposedly goes in the /Android/obb/package-name/ folder. To test it, we copy the file to that location using Windows file explorer.
To find the location, we call
String dir1 = Environment.getExternalStorageDirectory().getAbsolutePath();
However, on some device, it cant find the file
e.g. the GalaxyTab2.7.0 - the above call returns the location /storage/sdcard0, but it cant open the file /storage/sdcard0/Android/obb/package-name/base.tcf, even though we have copied it there, using Windows file explorer, to the Android/obb/package-name/ folder.
Now, maybe this "Android" folder is not the same one as the storage/sdcard one - maybe I CAN only put it on an sdcard ? But this same thing works on Nexus 10 and Sony Experia device, with the same paths, which don't have sd cards in them.
To get this working on other devices we had to put READ_EXTERNAL_STORAGE permissions in the manifest file. Maybe there is another permission ? Maybe once we actually download the expansion file, it will just work, but we can't test it otherwise.
Any ideas?
Thanks
Shaun Southern

Created files and can see them with DDMS but they do not appear within Windows file Explorer

I'm creating several .xml files for export.
Using
Environment.getExternalStorageDirectory();
I can export them successfully to the appropriate path I want to.
I can then see the files using DDMS. I can not however see the files on my device using the file explorer. Yes, I turned off debugging and can see all other files and folders.
You do not indicate what device you are seeing this on. If it is running Android 3.0 or higher, then you will need to scan the file. Quoting myself from a blog post:
However, there is a more subtle shift that is important to developers: the MTP contents are not based on the literal contents of external storage. Instead, MTP contents are based on what files have been scanned by MediaScannerConnection. If you write a file to external storage, until and unless that file is scanned by MediaScannerConnection, it will not be visible to users over MTP.
External storage is scanned on a reboot and possibly on a periodic basis. Users can manually force a scan via utilities like SDRescan. However, the best answer is for you to use scanFile() on MediaScannerConnection to update the media database after you close your file. This will make your file immediately available to the user.

How to load apk on device file system and start

I need to know how to load an application into a tablet where all I can do is a file transfer into the file storage area. I am using a tablet that does not have good eclipse usb integration, but I can put the file somewhere on the device, can someone please indicate where I need to place the apk and steps to load it after that. It is android 2.1 tablet Thanks
Just put the apk somewhere on your file system and open it with a file manager (ASTRO for example) in order to install it.
You have to activate "Settings" -> "Applications" -> "Unknown source" before.

Categories

Resources