Overwritten file not updated on Android - android

I am writing several files to a directory on the SD card, creating some and overwriting others. My tablet is connected to my Windows laptop, where I am looking at this directory and opening those files. In my Android app, after closing each file, I make sure to call MediaScannerConnection.scanFile(). This ensures that all the new files show up immediately, but somehow the overwritten files still seem to retain their original content--this is, until I unplug the USB cable and plug it back in.
This is on an Acer Iconia A500 running ICS.
Why isn't it working, and how do I fix it?

Related

Where do files *really* exist after doing`adb-sync`?

I'm playing around with syncing files from my laptop to my SD card on the phone using adb-sync.
adb-sync reports successfully pushing the files to the destination.
Navigating to /storage/9016-4EF8/Music in adb shell, the new files are listed, right after the following message:
ls: ./.android_secure: Permission denied
Yet the new files don't appear in my file explorer on the laptop. Additionally, they are not seen by my music player.
adb shell (different project - see comment) otherwise lists the contents of the SD card perfectly, AFAICT. It's only the adb-sync transfers that incorrectly show up as not being present.
Perhaps this is related, but adb shell reports success when creating new files, and these files also do not appear in my file explorer (Dolphin). Creating a new file in Dolphin works fine and is correctly listed in adb shell!
So I believe they weren't actually transferred. Or they were transferred somewhere strange in internal memory. Where might they actually be?
I've had a little time to clarify my thinking about this. Actually adb-sync is not necessary to this discussion. The problem is actually that filesystem operations within the adb shell are not reflected in the view from my file manager, Dolphin. So I launched the phone's file explorer and, voila, there's the changes!
So apparently this is a problem related to the much-decried MTP protocol. I'm happy to leave it at that unless someone else has something to add.

Having trouble creating bootable SD Card (TWRP + OTA + custom apk) to flash android TV box

Web Developer here. Normally, I don't have a problem with new technologies but Android (specifically marshmallow) has been the exception. It seems the search results I'm getting are garbage...muddied with all kinds of Windows-Android tools that I don't want to use, and on top of that, old makeshift processes for extracting files. It seems there isn't "one way" to edit an android files/firmware...whatever and that seems crazy.
Background:
I try to develop on OSX
Using Cordova, so I'm not developing natively.
I inherited a client with flashed Android TV box with custom firmware (Probox2 Air Amlogic s905x)
On boot, the device goes right to our apk (after initial setup), no android loading screen or anything.
I made an update to the devices main apk (v2) that requires me to update the existing .img backup (v1) to incorporate those changes.
Existing backup (v1) is a .img file (That is supposed to be able to flashed to the box using Amlogics USB_BURNING_TOOL) - F*$% that...I can't get my box to connect to my PC plus I'd rather not.
With the modded devices, I have never been able to connect them to my computers OSX or Windows. (no device connected notifications)
'adb shell' never finds the "connected" device (I should spend more time on this)
I've been able to flash from (stock device) > (TWRP update) using this csx tutorial but now that same sd card doesn't reinstall...TWRP boots
I've tried using these tools to aid my process without much success (as far as I can remember):
https://ibotpeaches.github.io/Apktool/documentation/
http://newandroidbook.com/tools/imgtool.html
I tried mounting the original .img file (v1) using OSXFuse to create a EXT4 partition on my mac to view the files but I wasn't able to get that working either. It couldn't partition correctly, i believe.
I tried mkbootingimg_tool it just moves the boot.img i extracted from TWRP to the build directory I specify.
My Goal:
Create an SD Card that it can be used to flash new devices. I want to be able to insert the SD Card into the box, hold the reset button, and it flashes itself.
Current situation:
I was able to construct a sd card that fit my goal and flashed successfully from (stock probox2 air device) -> (v1). I used this csx tutorial to do it.
That worked, my app launched fine and I used TWRP to make a back-up, just because.
But I cant unpack that original .img file (v1) because I can't tear it apart to make changes to my apk successfully, I've tried many things....
So then I started working with the TWRP backup files (I was able to update those apk files and repack most of the way back up) but I can't get a new working .img (v2) that flashes when its supposed to like it did when flashing v1 (it just boots to TWRP).
I can export this back-up to a sd card and view the files on my computer by renaming system.ext4.win to system.ext4.tar as described here and double clicking to extract. Then using http://www.javadecompilers.com/apk to open the custom apk that I need to change and repack (v2).
From what I gather, the process should go like this.
extract .img > extract the android partition (system.img or in this case system.ext4.win) > swap out apk then repackage in reverse order.
I just need some guidance.
Where am I going wrong? I feel like android studio should be all I need to do this...

Android keeps deleting my files while in recovery

I am trying to install a custom ROM on my HTC one m8. I unlocked the boot-loader, installed a custom recovery and everything works fine but whenever I try to put a custom ROM .zip on my SDcard, I see it with File Manager on my phone but if I reboot it on recover mode these files get deleted. I don't understand, help me please!
Resolved : sd card is too old and I can't write nor delete anything on it, I used adb push to put custom rom in the phone's internal memory

Files not appearing on SDcard despite being saved correctly; Appear in file explorer on device

Edit: Below is my original question, written for OpenCV in Android. I was saving files correctly but the files were not showing up in My Computer on my laptop! Strange enough, they were showing up in Astro File Manager. See the answer for more details...
I have read/write permissions enabled. The 'cm' matrix is NOT null.
I am trying to check my images during my processing process to make sure they are being formed the right way.
Here is my C++ code in the android native environment:
imwrite("/storage/emulated/0/stackovernose.jpg", cm);
cm is a MAT file.
/storage/emulated/0 is hard-coded from Environment.getExternalStorageDirectory(); The file is created, succesfully (the inner If tree is activated) but I can't find it on my phone? I've used similar code in the past and sometimes it works, and sometimes it doesn't. This time it's not working at all. What am I missing?
On some newer devices (Moto X, Nexus), you must disconnect, restart, and re-connect your device in order for your files to refresh in My Computer. Optionally, you can download a file manager from the play store to see your files immediately after they are generated.

Android: cannot access sdcard files from device

I'm working on an android app that writes and reads .PNG files from sdcard. I've already tried it on a device (htc) and it was working fine. Then I had to modify some code to correct some errors (Note that changes made had nothing to do with save/open function). But now just like that I can no longer save/open files on sdcard.
I've tried to open sdcard folder in DDMS File Explorer view (eclipse) but it appears empty and the permissions are d---------. I think it has something to do with the permissions but I have no idea what exactly is causing this problem and how to solve it.
To see if the problem was in my app I tested it on an emulator and it's working fine. So the problem is definitely related to the device.
Any suggestions?
Make sure you didn't connect the phone to your PC in "disk drive" mode.
I recall that in order to be able to view contents of certain directories with ddms you need to have rooted your phone to get the permissions.

Categories

Resources