Issue with file system android Quick Question - android

I have an app that saves files to the sd card but apparently some people that use the app don't see the file until they restart their phone. How can I fix this?

I've seen similar scenarios where files are not visible until application is closed. May be your users may "force close" the application just to be sure is an issue with your application.
My guess is that you may be are not closing the OutputStream object you use to write the files on the SD card, I mean, call out.close() method, where out is an instance of OutputStream.

Related

Protecting my app files(Android Studio)

Well hello, im working on a app that take a picture and then save it into the external storage, the problem that i get is when i use a external app, to clean up the cell phone memory, this kind of apps get into the folder where the pictures located, then deleted everything on it, i realy don't have any idea to protect them.
sorry for the problems with my English is not my native tongue
I think the problem is not yours. The problem is your cleaner's. Modify the cleaner's settings. Android cleaner like Clean Master is just weird. I don't know what kind of cleaning they do! Once they deleted my 150+ apps from my SD Card. So, if you are tensed about protecting your files from being deleted then it is worthless. You can't. Ok, think, a user is not using any cleaner to keep his/her phone tidy. But what will you do or how you will protect your files when the user is going to delete those files himself/herself?
The one thing you can do is - by achieving SuperUser permission from a user, you can just modify the SD Card's W/O or R/O system. But it has also some disadvantages. If you do something lile this, then you app may be introduced as a malicious program by your user. So, afterall, the answer is it isn't possible...
You should use:
getFilesDir()
This folder is located inside Android/data/data/your_package/ so no app except yours has access to it (unless it has root permission).

Can Android notify if is running out of internal or external storage?

If I'm constantly writing to a file located either in internal memory or SD card, there's a possibility that at some point there will be no more free space. This could throw an exception and create a corrupt file, depending on the way the file is written.
Can Android notify that it is running out of space, so that I can gracefully close the file?
The ACTION_DEVICE_STORAGE_LOW intent does not work for the SD card as far as I know.
Two ways to achieve this.
1) Check remaining memory in storage(there are many answers for this, just search), and decide if you want to create file or delete it. This is Recommended to check the storage before creating new files.
2) Have a subclass of Application class in your app, there is this method named onLowMemory which will let your application know when system is running on low memory.

Problems accessing local and remote files on Android

I have some problems accessing local files on my Android Application. I use FileInputStreamclass to access to a file on the SD card without any problems.
The issue appears when I close my application and add a new file to the SD Card manually. When I try to access this new one on my application it is not accessible (not found).
I think it has to be related to the cache that Android manage for every application.
I would like to clean this cache when my application is closed. Maybe it is due to the fact that when I close the application. (the activity) it is stopped but not closed, and the cacheis not cleaned.
Anyone has this trouble? Any ideas?
problem solved. On SD Card was due to a bad coding. Refreshing the SD files was done on OnCreate method in the Activity and was not executed altough the activity was closed. I've changed to OnStart and works fine.
And regarding the access to remote files on a servers I've used URLConnection.setUseCaches(false) and now is working fine too!
Thanks

Is it possible to track how many users have moved my app to SD card?

I'm interested in the analytics of how many users have moved my application to the SD card. Is there a way to determine this data? Ideally, I'd want to log an event that its been moved to the SD card (and vice-versa), but at this process is out with the application, I'm unsure how to go about getting what I want. For what its worth, I'm currently using Flurry for analytics. Thanks!
Check the path of your application files when the application is started. Edit: I was thinking of checking the running executable path, however that doesn't seem to work.
Have you tried the answer to How to detect when an App is force moved to SD-Card on rooted Android ?

android shared user id and reading/writing a file

I have been sufferring in one problem for several days.
Currently I'm running in the source code of "Settings" on Android2.2.
In AdroidMenifest.xml, we can see:
android:sharedUserId="android.uid.system"
With this, many permissions can be accessed for the activities in Settings.
But with this statement, the sd card can't be accessed for Read/Write, I have tried to read files in directory
File f = new File("/mnt/sdcard/"+filename);
or
File f = new File("/sdcard/"+filename);
But all of them don't work, I got an exception telling me that the file didn't exist (I have already put the file there).
If I delete android:sharedUserId="android.uid.system", then I can access the file successfully . However, I need the android:sharedUserId="android.uid.system"
to make the other activities run well.
Does anybody happened to meet the same problem, and have you solved it? Thanks!
The system user can not access the SD card, because if the SD card gets unmounted it may need to kill any processes that have files open on it and we don't want system processes being killed like that. If you want to access the SD card, you need to not use the system shared user ID.

Categories

Resources