I'm running into a problem where files stored in internal memory via context.openFileOutput() are disappearing after I force stop the app. I'll create 2 files, force stop the app, and when I open the app again they're gone. I'm verifying the file's existence by using context.fileList(). My understanding is that this storage is persistent, but I'm not seeing that. Is there something I'm missing?
Your help is greatly appreciated.
I think my question could have been phrased more pointedly. I didn't post code because I was hoping to hear if anyone had similar experiences or knew of any circumstances that would lead to this sort of behavior.
I did some further testing and found that the storage is very persistent; the behavior I was seeing was a compounded blend of inappropriate and inconsistent methods of interacting with the storage, as well as a broken serializer.
Related
I'm looking for someone who might be able to suggest ANYTHING that might explain this problem I've been having. I've been having this problem for almost three years, with the same app, and nothing I have tried fixes it, or even explains what's going on. The app is a little game, and it saves its state in three files inside one level of folder, like so:
USERNAME
gamestate1.dat
gameinfo.dat
gamestuff.cfg
So what happens is, people will play the game, then suddenly the next day they'll play it again and data will be wiped. Sometimes all files (and the folder) are gone. Sometimes one or two files are missing. It's not common,but it's happening enough that it's occupying too much support time.
The game itself has nothing in it that deletes files at all. The game doesn't delete. But the files are vanishing somehow anyway. The game is not a hardcore game for hardcore players, so most of my users are tech-ignorant, so I know they're not going in an deleting the files.
The rate of customers complaining that they've lost everything increases exponentially right after I push an update.
Can anyone tell me if there's ANY kind of special situation on android that could cause this, and how I could prevent it? Is some antivirus on some phones? Could it be sectors on the card going bad? I've tried turning Google sync on and off and every which way, and turning sync off seems to reduce the problem without eliminating it.
I'm using JNI and accessing my files with normal C++ file functions-- fopen, fwrite, fread, fclose. I am saving them in the folder returned via getExternalFilesDir(null).getAbsolutePath().
I'm fairly new to Android and I have been working from the past couple of days with images that I save to internal storage and then assign it to different elements (just for testing), like a button (with setBackground) or to an ImageView. In every single instance this message of not a DRM File appears on the LogCat.
I've been trying to find what this means, but with no luck. I'd really appreciate if anyone could shed some light into this subject.
PS: This is my first post in this forum so I apologize in advance if I'm making any mistakes or omissions while forming this question. Thanks for the understanding!
UPDATE: Just to add some results I got yesterday from testing, apparently generating Drawables from images in internal storage make this type of message appear and Android is unable to decode said images, however if those images are moved to external storage then they can be converted to Drawables and work without problems. Hope this can help anyone else stuck in this kind of situation.
DRM stands for Digital Rights Management. It's normally a special keys used by owners of content to make sure that your device is authorized to view/play the content. iTunes was notorious for this for ages.
All it's doing is letting you know that the material you are opening is not DRM protected, and therefore can be opened normally.
When my application opens a SQLite database, a message is written to the log similar to the following:
dbopen(): path = /data/data/myApp/databases/myDb.s3db
Although I know that people with an unrooted phone will not be able to access that part of the system, I don't particularly like that the path is displayed for anyone to see who might glance at the logs. Plus, people with a rooted phone COULD access the database and it may contain sensitive information.
I know, I know, I should encrypt sensitive data - and I do. The question remains, however, does anyone know how to disable that log message? I haven't yet found a way.
I thank all of you in advance.
I'm not too sure why you're worried about if someone with root, because that won't stop ANYONE with root (disabling the log). It's not hard to just CD into your folder, I have hacked many games in this way.
Just use data structures and save to a file...To my best knowledge you can't disable SQLite logging.
I need to block user access to my app's data stored in the SD card... like the images etc as they are crucial to my app's proper functioning and if deleted by mistake, will cause the application to function way different from what is expected of it. Is there any way to do so programmatically, like when I create this directory structure during my first run, lock the access to it to be only unlocked when the app runs?
Short answer... NO, it's not possible at all.
If it's that important, you could store all your data in a encrypted file. That way if it's deleted then you know it's all deleted and you have to start again. You also know that it's 'most likely' haven't been tampered with.
Most likely tho, the best solution is to handle errors better and become a more robust application.
Can an android app read the memory (the RAM meory) of another app that is running?
Appreciate any pointers.
Do you mean the part of the memory that another app is using for code? Then No.
I assume that someone might find a way, but that would be a security issue, a bug in the system and something that would be adressed in an update. You should stay out of 'other' pieces of RAM.
Or do you mean something like internal memory where you can store a file? An app can save a file in several ways, including some that let other apps read them (example: if you take a picture with a cam-app, you can read it with any gallery app).