Android prevent indexing of files on a sd card - android

Is there a way to prevent android os from indexing files on a sd card? We have an application that uses offline map tiles and even for just one city its about 3 million files.
Every time we reboot the device or insert an sd card the android.process.media process runs for about 2 hours trying to index everything on the sd card. Which also for some reason causes the media storage app to fill up all the hard disk space on the device.
We've tried using a .nomedia file in our map tiles folder but it does not seem to make any difference.

This is a total hack but what works for us is moving whatever you don't want indexed into the Android/data folder on the sd card.

Related

Recover corrupted SD card

A friend of mine gave me a corrupted SD card. My windows 10 cannot detect it and on android it asks to format the corrupted SD card. Is there a way to partially or, best case, fully recover the data on this card?
Kind regards
Kurt
First thing you need to determine is if it's detected with correct capacity in disk management:
This is what to look for in Disk Management
If not then this is probably not DIY-able. A data recovery lab still could get the data by scraping off the back layer and soldering wires to a special reader.
If it is detected, my advise would be to create a sector by sector image file. Then, any decent file recovery software should be able to scan that image file as if it were a regular drive and recover the data.
To create such an image in Windows you could use Win32 Disk Imager, in Linux ddrescue. Any decent file recovery tool would allow you to create a drive image too.
I'll mention DMDE as an example as it is also a very good tool to analyze the image file with and recovers upto 4000 files for free (as long as they're in the same folder).

What is the expected behaviour of Adoptable Storage on Android M and how it should be handled by apps?

I am experimenting with the “Adoptable storage” introduced in Android Marshmallow and I need some guidance on the expected behaviour and how the apps should handle the “Adoptable storage”.
Format “micro SD” card as Adoptable storage by using “Format as Internal”
Once Format is done, there are 2 options given to the user as follows:
Move Now
Move Later
a. Move Now:
When this option is chosen by the user, the path returned by the getExternalFilesDirs
is “/storage/emulated/0/Android/data/PACKAGE_NAME/files” and it actually points to the file system of micro SD card.
b. Move Later:
When this option is chosen by the user, the path returned by the getExternalFilesDirs
is “/storage/emulated/0/Android/data/PACKAGE_NAME/files” and it actually points to the file system of Internal embedded memory.
In both the cases, the apps can see only one storage and the other storage is completely not accessible by the Apps to store data such as Photos, Videos, etc. Is there any way to access the storage paths of both the Internal and micro SD card when the micro SD card is formatted as “Adoptable storage” ?
Apart from this documentation ,I could not find a detailed documentation on how the apps should handle this adopted storage. Is there any API that app needs to use?
Example:
Let say, if the user phone has Internal memory of 32 GB and micro SD card of 32 GB.
If the card is formatted as “Portable storage”, both 32GB(Internal) and 32GB(micro SD card) are available to user to store data.
But If the user format the card as “Internal Memory”, the user can save data(photos/video/music,etc) only to any of this 32 GB storage location, but not to the both location. The system is providing an option of “Migrating data” between the storage locations(Internal to micro SD card and viceversa), but the apps can use only 32 GB of storage(The user effectively loses his 32 GB of storage to store Media files and can be only used to install the apps ?).
Is this the expected behaviour ?
Note: Test devices used - Moto X Play & HTC 10 - Both running Android 6.0.1
getExternalFilesDir() always points to the external storage, which may or may not be available. Use getFilesDir() to dynamically get the path to wherever the App is currently stored.
Don't store the result of this since Adoptable Storage may move your app around at any time. From the docs:
The returned path may change over time if the calling app is moved to an adopted storage device, so only relative paths should be persisted.

How does Android calculate cache and data size?

How is the size of cache and data calculated in the application properties?
I save all my data to the SD card, but Android shows me that I'm constantly using 4 KB, but on the SD card are about 50 KB. The same with the cache! I put a 3 MB picture in there. But my cache size is zero!
I think I'm using the correct directory: /mnt/sdcard/Android/data/my.package.name/files and /mnt/sdcard/Android/data/my.package.name/cache.
Has this changed in Android 4.0.x?
See this screenshot:
I believe the Cache size is the size of the Internal Cache directory that is returned by http://developer.android.com/reference/android/content/Context.html#getCacheDir()
I think you've used:
http://developer.android.com/reference/android/content/Context.html#getExternalCacheDir()
The application properties page only shows usage for the internal memory, not for the external memory (SD card).
I don't know exactly why they chose to do it like this, but one reason would be that the SD card is not managed to the same degree: while you can get Android to manage SD card data for your application, you can also bypass it and use a custom folder structure.
Additionally, external memory is usually far larger than the internal memory, and can be managed by the user, so SD card usage is probably not all that important anyway.

what is the exact path to store files in SD card

I have a requirement that I need to copy some files to the SD card programatically.
I have used
Environment.getExternalStorageDirectory()
to refer the SD card but In some devices it is referring to internal memory of the device.
Then I tried "/mnt/sdcard/" this path also still referring to Internal memory of the device.
I have done some investigation and came to know that "Environment.getExternalStorageDirectory()" will refer to internal memory of the device.
But I want to always store my files in SD card for all the devices.
I just want to know the path which should always refer to the Sd card in all the devices.
Is there any hard coded way to do this..??
Please help me.
Android doesn't know anything about the way the data is physically stored (could be a SD card, a CD, a chipset, etc). The only thing it knows is about whether the storage is "internal" or "external" (more details here).
So the way you are doing is fine: if the system gives you a path to an internal chipset when you call getExternalStorageDirectory(), this means that your physical device is built that way. There is no workaround for that.

Low level operations with SD card on Android

is it possible to have low level access in Android with Java/NDK to create for example card scanner like scandisk or card defragmenter? I move a lots of stuff around my card and it gets fragmented quickly. I have experience with FAT32 defragmenting on Windows, but I'dliek to do this on Android.
Fragmentation does not affect SD card as much as it affect a harddrive since SD card does not have spinning parts or moving heads, the difference between random access vs sequential access of an SD card is negligible.
In other words, SD card does not need defragmenting; in fact defragmenting an SD card will only lower the life span of your SD card since the memory cells of an SD card have a limit on the number of read/write that you can do on them.
And if you need to "scandisk" (or "fsck" in Unix/Linux-speak, stands for "File System ChecK"), I don't think the Android's default shell comes with fsck, but you should be able to fsck the SD card from your computer.
Maybe this is related to one of my questions.

Categories

Resources