First, let me say that today is the first time I've ask a question on SO, so please be tolerant if I don't phrase my question according to the rules or make myself clear. I have reviewed these problems in SO and can't seem to find an up-to-date solution THAT ACTUALLY WORKS.
My problems deal with creating and accessing files being transferred between Windows and Android 11.
I have an android karaoke app that reads karaoke files previously transferred from Windows. I manually created a 'Karaoke' folder on an external SD card and manually copied the karaoke MP3 and CDG files into that folder's sub-folders. I was then able to programmatically access those files within my app. Under Android 11, I can still access the MP3 files but not the CDG files. What is the best option to solve this problem.
Likewise, I was backing up my app database located in protected storage to the removable SD card. I could then manually transfer the backup files to Windows. This no longer works under Android 11. What is the best option to solve this problem.
I am confused with the new app storage system in Android. I am not sure where my use case falls under and I need your help in telling me the right approach for this
My app captures images and generates pdf documents. Prior to Android 10, I used to store them in an app directory where the user can easily navigate to them through other files browsing app (like Files app on Samsung). In addition, these files can be accessed from within my app (so essentially read and write).
With the new storage, I am not sure how to accomplish the same thing. If I use the internal storage then user can't see them. If I use the media approach, well it seems it is only for Audio/video plus they will not be organized in a folder like I have them organized.
Am I missing something? How would I solve this problem?
Thank you
On an Android 11 device you can store your files in a subdirectory of the public Documents directory.
You can do that using classic File means or the media store or SAF.
Other apps can see them using SAF or the media store. Or with classic file means when requested all files access.
The user can see them using the default Files app on the device.
I want to create an application that is able to override the lock.ogg and unlock.ogg for Android phone without needing to root your phone. But I don't know how to code these properly nor if it's possible programmatically on Android Studio
Here's my basic idea:
Perform file searching to obtain all the ogg files stored in the phone.
When user has confirmed the sound, the app will copy the file (so that the original file's name is not overwritten), then rename the copied file to lock.ogg/unlock.ogg.
The problem for me is that other than implementing the ogg explorer, I also have to code the destination of the new ogg file to /system/media/audio/ui/ to overwrite the previous lock and unlock sound.
Is this possible using Android Studio?
I'm a newbie on Android Studio.
I am making an android application. I would like to know as to how to make a program to hide files from the android phone.Like the "Hide it pro" application
I think there are three options:
Move the file in a directory which is not visible to other apps.
Encrypt the files and let them public (that means accessable for other apps)
Add into your directory where the files are inside a .nomedia file. But note that this just hide the files from the MediaScanner. But it will be simple accessable for other apps if they look into your directory.
By the way your operating system does not matter in any way. Just the target platform counts.
"Hiding your files from the Media Scanner
Include an empty file named .nomedia in your external files directory
(note the dot prefix in the filename). This will prevent Android's
media scanner from reading your media files and including them in apps
like Gallery or Music."
http://developer.android.com/guide/topics/data/data-storage.html
This won't hide files from the OS (or "the android phone") but it will prevent MediaScanner from picking them up and displaying them in built in apps. NOTE: In Android 4.0 there was an issue where existing indexed files were/are not forgotten if a NEW .nomedia file is created. To work around this create a new directory, add the .nomedia file, and move content you want to hide there.
I have images, which are read from sdcard only by particular application so I want to hide it from image gallery. I have put .nomedia file in it, but this file is ignored, images are still showing in Gallery. I have put it with "." in the beginning. Still not working. Any ideas?
I'm guessing you're using Android 4.0, as .nomedia functioned properly until then. The AOSP bug report for the issue explains:
MediaScanner on Android 4.0 fails to forget already-indexed files when it encounters a .nomedia file, but it does honor it if it's present on the first pass. So the workaround is to simply rename the directory. Of course you can change the name back after the next scan, if you like.
Update: I suppose the complete solution would be to actually force a media scan after renaming the directory. I haven't tried it, but something like this should do the trick:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" +
Environment.getExternalStorageDirectory())));
Well... I admit I'm only guessing, but since it got a +1 in the comment, I'll give it a whirl as an answer. Since this is your own app, change the image file's extension to something totally unique ".myimagefile" for instance, and see if that hides it from Android. Meanwhile you know what files to load into your own app, and how to save them.
The .nomedia bug is right and you CAN add it to a preexisting image folder.
You can force the gallery to re-index after you created the .nomedia file by renaming the folder, run gallery (the "hidden folder should now be missing), and rename the folder back to what you want. It should remain hidden.
I just did it again to ensure it works on my phone. Android 4.0.4.
Here's something I found myself:
http://www.transformerforums.com/forum/asus-transformer-faq/17765-solved-nomedia-doesnt-work-under-honeycomb-ics.html
However, a little alteration to that method:
Download and install SDRescan app
Clear data for Gallery app
Clear data for Media Storage app
Open SDRescan app downloaded from step 1
SDCard should be re-scanned and all directories containing .nomedia files should be ignored at this point.
In my memory card I have thousands of photos that overwhelm the media-scanner. Then in the root folder on my memory card, renamed from "RootFolder" to ".RootFolder"
Became the hidden directory and not use more .nomedia
Try this.
The .nomedia file is preventive, not curative (in Android 4.0), and it is a bug.
If you had a .nomedia file and images are already in it, Gallery will still search for images.
You need to create your .nomedia file before puting images in it.
Edit: all folders starting with a dot are not scanned (because hidden).
With Media Storage 4.1.1 on my Samsung Galaxy Note 2, none of the tricks given above works fully, in this sense: directories containing .nomedia files are still scanned, which can drain the battery a lot (though the result is ignored in the gallery), and also directories with names starting with a '.' are still scanned :-(
I resorted to using the "Media Scanner Root" app, which allows to disable the crappy media scanner altogether. This is apparently achieved by something like pm disable com.android.providers.media/com.android.providers.media.MediaScannerReceiver
BTW, disabling/freezing the Media Storage app itself has the bad effect that the selection and binding of ringtones and notifications does not work any more (what a wonderful design), but when only disabling its scanner component, one can still use, e.g., the ES File Explorer for selecting tones.
Gallery is not updated so often and some thumbnails are still on the view. For this u need to reboot the phone or programmatically update gallery, by following code.
/**
* This method is must to reflect changes on gallery, if some file is
* deleted or moved, <b> no updation is shown on gallery till phone is
* rebooted </b> or <i>till this method UpdateGallery(Activity activity) is
* called</i> UpdateGallery
*/
public static void UpdateGallery(Activity activity) {
activity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri
.parse("file://" + Environment.getExternalStorageDirectory())));
}
You might consider using the APK Expansion Zip Library (requires API level 5 or above) to read files that you will have installed to the SD card as part of a Zip archive. A description of this library can be found here:
http://developer.android.com/guide/market/expansion-files.html#ZipLib
Presumably, files stored in a ZIP archive on your SD card will not be displayed by the Gallery.
In addition, if you have images that your app reads from (but does not write to) the SD card, and that should only be available to your own app, and that could be delivered when your app is installed or updated, then it might make sense to take advantage of a new Google Play facility to incorporate them as part of your app when it is installed.
I'm guessing that you are storing your images to the SD card because they are too large to fit into your APK file (given its 50MB size limit, which is even smaller than that in practice for certain devices, due to buffering issues).
If so, then you might consider that Google Play, as of 3/5/2012, supports the attachment (to your app) of up to two "expansion files" of up to 2 Gigabytes each. The APK still has a 50MB maximum, but the expansion files raise the total storage available to over 4 GB. Those expansion files are served for you by Google, and they are maintained in a specific SD card folder that is specific to your app, and can be accessed using an API provided by the Downloader Library (requires API level 5 or above).
Here is Google's announcement of this change:
http://android-developers.blogspot.in/2012/03/android-apps-break-50mb-barrier.html
And here is a detailed description of the facility:
http://developer.android.com/guide/market/expansion-files.html
Note that while this facility is new, the libraries have been supplied with the Android SDK for use with earlier API levels. For example, on my installation, I find the API-8 versions here:
<Android SDK base folder>\extras\google\play_apk_expansion\
That same folder includes the abovementioned APK expansion Zip library in its zip_file sub-folder.
I have not personally used this facility yet myself, and so am describing this based solely on the cited references.