Android not enough storage memory - android

I created an Android app sometime ago. What the app does is basically download a list of files (images and videos) and play them in a loop (like a Playlist).
These files are saved in the default Android External Storage Directory. I get it using this method:
Environment.getExternalStorageDirectory().getAbsolutePath();
Until now I never had storage problems but testing the app on an old device (which has less storage capacity) I realised that I have a problem when the files (PlayList) size is bigger than the device storage capacity.
I have thought (and research) about using an USB stick, but I don't think that would be a good solution since I cannot know 100% sure the USB path (it can be different for each device).
Any ideas about how handle this problem? Maybe another solution instead of using the USB ?
Here is what I have researched:
How to access USB Path in android?
How to find USB storage path programmatically?
android How to write files to a usb memory?

Do you need to store the actual images and videos on the device - why not just store their location and get them dynamically. I've not used a recyclerView but I thought that it could do something like this, but could be wrong.

Related

Cannot play downloaded Amazon Prime videos offline when saved to SD card

from my galaxy tab s3, I can download and play videos offline with the Amazon Prime app if I save them to my internal storage. However, if I save them to my sandisk mirco sdCard (200gb), the downloads seems to complete successfully, but I cannot play the videos. The same offline watching works fine with Netflix.
Is this a known limitation of Prime, or is there some way to troubleshoot this?
a while ago GOOGLE and the ANDROID team had made it so that certain things cannot be accessed or written to the SD card due to exploits. it has been this way since 4.1 i think?
Unless there's an option to specify the SD card with the application, i doubt it
You did save the files using the application correct? or did ya move them from the Internal to the external? if you did this then that might be the issue. you will have to put the save path as the SD card if it allows it. if not, then blame google for screwing with how Android devices read/write permissions with the SD card.
also this really isnt the place to ask these question, you SHOULD contact AMAZON customer support....
looks like its an sd card issue, since I tried reformatting it both in my GalaxyTabS3 and on my fedora machine, and i get errors. false alarm...

android internal storage data recovery in 4.4.2

I am trying to recover deleted photos from android 4.4.2 lg g2's internal storage, As I cannot connect the internal storage as a USB Mass Storage or as an Disk Drive, I cannot run any of the data recovery software.
If there are possibilities to connect as an USB Mass Storage or Disk Drive, or if there is totally different method to achieve this, Please let me know.
Edit : Wondershare Dr.Fone for android seems to be the only software that can scan, but it does not retrieve encrypted Images.
The program that I would use at work to recover deleted files or files from a failing hard drive is called Disk Drill. The one we used was for OS X but it looks like there is also a version from windows.
Although from the years of use I had with it, it was able to recover files that were deleted as long as that part of the disk had not been written over again. It will scan the disk and literally grab every file it can, even things that might be half way deleted or corrupt. If the device was encrypted it might have a more difficult time getting files back. I have not used it on a android devices but I would give it a shot.

External Storage Write Access for Kitkat devices

The Problem
My app supports 4.0+ and it is all about file handling. It works perfectly in all Android versions except Kitkat.
In Kitkat, my app is unable to modify or write any files in SD card. But I see various apps like,
1) Solid Explorer
2) ES File Explorer
3) CamScanner
4) UC Browser
All of these apps give write access to SD card even in Kitkat devices without even root access.
Requirements
I need to have a fully functional way to create or modify files stored in the SD card in Kitkat. I seems to have troubles a lot of users and a proper solution will help many developers like me.
Yeah I came across that problem as well. After a lot of reading across the web the solution is to write only in your app folder (Ex: /sdcard/Android/data/packagename).
About those apps, on my s4 mini, es explorer cannot delete from external sdcard, so I think is different from device to device.
If the devices is routed change the permissions to gain write access anywhere on the sdcard.

SDCard content exist but cant see them

I am having very Strange problem with my Samsung Nexus with Android 4.0.2. I wrote a simple program which basically create file each time user presses a button. My program is working great on other devices where as on Galaxy Nexus Windows/Mac can not see those files on SD card, but when i do adb shell i see all files on SD Card.
I retest this on another Nexus which has Android 4.0.4 but still same result.
What could be the reason?
You probably need to index your files via MediaScannerConnection. Quoting myself from a blog post from last year:
...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.

Watch for changes in external USB storage for Honeycomb or later Android versions

I've got a DSLR camera and Samsung Galaxy Tab running Android Honeycomb. DSLR connected to a tablet using USB-cable (via USB kit enabling host functionality on a tablet). I'd like to being notified when user takes a photo using this external camera, in order to download this image to the tablet or do something else with it like showing Toast notification containing meta-information taken from the image.
As far as I get all of the existing tools (like FileObserver using underlying inotify mechanism, MediaContentProvider etc) allowing to watch for changes, demand a specific file or a filesystem path to be watched. This was good enough till we had a block layer protocol support in 2.x and earlier Android versions - when you connected device it'd been mounted somewhere on the device's filesystem and you was able to use this mountpoint as a watch point for those tools.
Since Honeycomb Google has changed the way of accessing external USB devices to Media Transfer Protocol with PTP as a subset of this. Now when I connect external USB device to an Android device I won't see any mountpoints for it (I'm using adb shell and subsequent mount command for getting them). Moreover, MTP implementation uses storage ids which apparently act as a higher level of abstraction and are just plain integer values. I was hoping there is a way to somehow translate these storage ids to the real paths/mountpoint/whatever but apparently there does not appear to be.
Thinking about Android MediaScanner which is already running on my device I guessed it could manage this issue with a special Intent broadcasted when there're changes in media files accessible from the device, so I started looking for already existing and suitable Intents for being notified, but no luck - I found only ACTION_MEDIA_MOUNTED and ACTION_MEDIA_REMOVED which are broadcasted only when device is connected and disconnected respectively. That means MediaScanner can't notice any changes on the device until you remount it (I've double checked it using stock Gallery app - it doesn't see any newly created images on the camera until you unplug and then plug it into the Android device again).
Trying to get this mount path for external sdcard, I used Environment.getExternalStorageDirectory() API call but it yields emulated Galaxy's sdcard path
which is /mnt/sdcard, not the camera's one. So it doesn't work for me either.
I managed to work out this issue only having launched periodic Timer event with AsyncTask acting as a TimerTask. This task does initialize usb connection, open device,
scan the whole device memory, getting only the last taken photo and then close device descriptor and usb connection.
It doesn't look like the best and efficient way of doing that taking into account it has to do all of these actions every time which could be pretty often, say each 5 or 10 seconds. It definitely quickly drains battery out and produces unnecessary system I/O for only taking last taken photo and comparing it with the previous last taken photo (in 99% it'd the same image), but I haven't found any better working solution for doing this. It'd much better off to have an observer mechanism with event-based notifications.
So my question is there more efficient way of being notified about changes in external USB storage for Honeycomb or later Android versions rather than one described above?
If you would like a more efficient way the camera would have to send out some sort of signal over usb that it has taken a photo. I guess it is not doing that.
Therefore you will have to check manually by doing the way your are discribing:
mount storage --> check for changes --> do your thing with your detected changes.
I dont know what you used to read "the MTP way" but here an example application:
https://github.com/ynakanishi/Honeycomb-MTP-sample
To not scan the entire storage every time you could save the result of read out file names for example every time you check and compare it to find the new ones. Usually the naming of the file also starts with the same number on a camera. So if you start a session with an empty sd card you know already the file name the photo will have. lets say img0001.jpg. So you just need to write a function to grab that file until it succeeds. if you want the next one img0002.jpg you can write a task/service/function to grab that file until successful, and so on.
If you want to save on battery you could implement an additional battery/power source inbetween for powering the usb port.
Instead of an Async task or timerTask you could try a ScheduledExecutorService and see if it uses less power.
Hope that gave you some new thoughts

Categories

Resources