Certain Phones delete SQLite DB - java

I've got an app created with Android Studio.
I'm using an SQLite database which gets downloaded and saved in phone's storage.
The problem is that in certain types of phones (Lenovo / Xiaomi to be exact) the sqlite file gets deleted after some time and the users have to re-download it.
The problem is appearing only on these 2 types of phones and also not all of them.
I can't replicate that on any of the phones I tried nor emulated ones within Android Studio.
There is no code that would delete the SQLite file and also I couldn't find anything in here or google about Lenovo/Xiaomi having similar problems like mine.
Any Ideas, would be appreciated.

I don't know about Lenovo, but Xiaomi phones have a "Clean up" feature that regularly (at least once a week, in my experience) asks the user to, well, let it clean up files. I don't know what it uses to decide if a file is obsolete or not, but it is a very aggressive cleaner (it wants to clean up cache files for apps that have just been used and are in constant use, for example). This is likely what is removing your downloaded files. You can check the location you're downloading them to, and see if changing that helps; or you could see if you can find any documentation on the file cleaner so you can find out how to stop it from flagging your DB as "rubbish".

Related

How do I create a directory at /0 on Android?

I'm having a problem with my users (Android). They delete the app, and their data is gone. They expect it not to be.
Browsing my phone, I see a lot of apps put a folder right off of /internal shared storage. I.E. I click on internal shared storage and there's a bunch of folders for various apps with data in them that doesn't go away if I uninstall the app.
This is what my customers want. This is what will stop them from writing me and accusing me of destroying their data.
How do I get a path to that folder, and what permission do I need to write there?
First off, deleting when the app is gone is how Android works. Anything else is a bug that you should expect to see fixed.
Secondly, you can't put anything right in / anymore. There was a time you could, but that's long since gone.
Third, have you looked into Android Data Backup? https://developer.android.com/guide/topics/data/backup This will work even on a new device, so its a better path forward anyway

Programmatically write to an android device

I would like to write a program in java that copies mp3 files from my PC, renames them so they sort correctly, and transfers them to the sdCard on my Android phone via USB. I assumed this would be a trivial task since I have already successfully written a similar program for transferring files to an external HDD, however I reached an immediate stumbling block. It seems that java (and indeed other desktop applications) cannot locate the device's file system even when given the exact path that windows explorer reports (This PC\SAMSUNG-SM-G900V\Card).
I've tried researching and the problem seems to have to do with the device being considered a Portable Device rather than a drive (maybe) but I have not found a concrete solution. An answer to the following question seems to suggest it is impossible but I find that hard to believe.
Can Android's internal memory be mapped to a drive letter on PC?
Does anyone know of a way to access Portable Device storage through java? If if it indeed impossible, can someone perhaps help me understand why it is possible through Windows Explorer but not through other programs.

Android - Server could not process your apk - Size limit?

I spent all day trying to figure out what is wrong with my apk. Tried ALL solutions from web, aapt revealed nothing, tried different signatures, packages, versions, browsers, OS. Manifest underwent all possible changes, yet I was getting same problem.
So I though OK, lets start from scratch, maybe google servers are down for some reason (wouldn't be the first time).
created new android application project, new package, just one activity
built, signed, uploaded, voila, OK, fine, removed apk from console
did this few times, it succeeded every time
the size of apk was few hundreds KB
as my original apk was around 25MB, I thought, hey, lets try increasing size of this testing one
so copied ~25MB worth of photos to drawable-hdpi
built, signed, uploaded and familiar message popped out again - 'Server could not process your apk'
tried several times, still same outcome
deleted photos, built, signed, uploaded, ok
added photos, no luck
So obviously problem is not in manifest or anything else, for some reason size matters (in this case anyway :)).
And yeah, when I deleted just 50% of photos, so apk was ~ 13MB, it sometimes worked, sometimes didn't.
Any explanation for this? Can you replicate? Have tried different browsers, operating systems, same everywhere ... I know there is a limit for apk size, but that's 50MB
Go figure ...
UPDATE: if you ever encounter same problem and you're sure your apk is fine, keep trying to upload. It worked after couple of consequent failed uploads, suddenly server COULD process, without ANY change to apk.
I don't know what's going on with your app and Google Play. Our largest APK file is just under 11MB and we've never had a problem.
Perhaps you can side-step the problem by packaging up the resources in an APK expansion file, as described here. The size limit for APK expansion files is 2GB, so there shouldn't be any size issues at all. According to this thread it can be set up to work pretty smoothly (transparently for the user).

Galaxy Tab 7 Plus. Two sdcards. How to choose?

My app is used in my job to make sales.
This app can remotely update itself (not using Google play), update its data, send information, etc...
In some point, the app reads a heavy catalog of images (several hundreds of MB). To avoid download this data, a micro SD card with all the images has been included in each device.
To read the images in the SD Card I use "Environment.getExternalStorageDirectory()". Until today everything worked ok.
However, the new devices are GalaxyTab 7 Plus, they are very cool machines, but when I use "Environment.getExternalStorageDirectory()" I got the internal SD path. The tablet recognized the External SD card (as "extSdCard") but I don't know how to access it.
I tried with the "vold.fstab" file (following the answer to this question How could i get the correct external storage on Samsung and all other devices?) but I don't trust too much... I mean... is this thing valid? I checked the vold.fstab from a GalaxyTab 10 with android 3.0 and a GalaxyTab 7 Plus with android 4.0 and they are pretty different...
So, in short:
I always want get the external SD card path and if this does not exist, then get the internal SD card path (if exists). I can't do this because java don't let me choose between then when I use "Environment.getExternalStorageDirectory()"
Thanks!
The Android SDK, at least through 4.1, does not support the notion of multiple points of external storage. Hence, there is no documented and supported means for you to get to this secondary card from a directory standpoint.
The contents of that card may be indexed by the MediaStore, through proprietary extensions added by the device manufacturer. Every device that has an external SD card that I have tried appears to do this. Hence, if there is a way you can somehow adjust your logic to not worry about where the files are, but instead to find them via MediaStore, that should work across devices.
Beyond that, you're stuck with guessing games, per some of the answers on the question that you linked to.

Pull files from Android tablet for debugging purposes.

In school (high school), my partner and I are developing an Android tablet application. We were both issued Acer Iconia A500 tablets to use. I need to pull files created by our application on run-time off the device (adb pull), but because they are not rooted, and I wouldn't want to root school property, is there an effective way to remove files from an android device stored in your applications data/data/packagename/ area? We also did try the emulator, but have had numerous different problems with it, and when it does work, it takes about 4-5 minutes to upload an apk to it every time I change code and re-upload it. Any ideas on a good way to get files off a non-rooted device, in this case a database I'm trying to copy from assets, so I can inspect it?
If you have a choice, I'd definitely recommend writing your files to the SD card because that will be a lot easier to view and handle.
If your file must necessarily be written in /data, what you could do is mirror it to the SD card for debugging purposes. So every time you write the file, you also write exactly the same content to the SD card (if the debug flag is on, otherwise no).
If it's a file that is not being created by your code but by other code, what you can do in your app is copy it to the SD card when you detect that it's been changed.
You could use the external storage permission and write to the SD Card instead. Then you can pull them using the regular windows directory when you plug it in. Also, it should not take that long to update your code via the emulator, are you turning the emulator off every time?

Categories

Resources