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

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

Related

Certain Phones delete SQLite DB

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".

Preventing the file to be downloaded on other device

I want to create an paid app which has a file which can be downloaded.If users buys my application and downloads the file.I want disable the user from transferring that file any other device.Some kind of Cyptography i guess.I have searched everywhere but no luck.Please guys help me to achieve that.
You would either have to hack the Android operating system in order to do that, or you would need to make a program that keeps checking what eachfile the user opens is.

Recieve constant updates from Google Drive API Android AppDataFolder?

I have created an Android application in which it is able to read files from the Google Drive Hidden AppData folder and react based on whether specific filenames are present.
I have created a separate external interface that creates a file in this folder and it seems to do it successfully.
The problem I have is that I can't seem to find a work around for having my android application constantly listening/receiving updates from the appdata folder.
The odd thing is, is that sometimes the application will pick up the file change straight away but other times it can take hours.
I'm convinced that Google's 'OnChangeSubscription' method they provide in the developer documentation doesn't actually work.
Any suggestions on methods I could try/where people have been successful at this would be great as I have been at it for weeks and it's the final thing I have left to do.

Do something before app removing

I've got an app that stores few files on sd card. I want my app to remove those files, if user wants to delete the application. How can I do that? Is there a method like onDelete() or something?
I've got an app that stores few files on sd card. I want my app to
remove those files,
Don't store them directly on the sdcard. Use the app's cache space or the directory pointed by getExternalFilesDir. Both are cleaned up by the system when the app is uninstalled
No, there is no way for you app to know when it is being deleted/removed from a device.
Intent.ACTION_PACKAGE_REMOVED
Broadcast Action: An existing application package has been removed from the device.
The data contains the name of the package. The package that is being installed does not receive this Intent.
This comes mostly because if a code would be executed on the app that was about to be removed some might prevent removal etc.
You should provide an option to your users to wipe sdcard data, or use another storage option (that is linked to your app), but I guess you're using the sdcard on purpose.

Reinstall application apk programmatically without downloading

Due to this annoying Android limitation I need users to reinstall my application so the manifest permissions are detected by other applications.
This is already going to be frustrating for the user, but in addition, I cannot see a way to reinstall my application from the apk stored in /data/app and I would therefore have to download the same version to the storage card before firing the usual install intent.
I eagerly await someone telling me that I'm missing something obvious! I've drawn a blank...
Thanks in advance.
Please do star the issue if you'd like to see it resolved! Cheers.
EDIT: With the comments of #hackbod in mind, you can use the following code to initiate the install dialog.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(this.getApplicationInfo().sourceDir)),
"application/vnd.android.package-archive");
startActivity(intent);
On my Jelly Bean device, this presents two options: Package installer and Verify and install. I don't know if the latter will deal with the issue of:
Installing your app this way will probably remove ownership of it from the Play Store
My application is free, so I cannot test the paid issue of:
Note however if your app is forward locked (which is unavoidable for all paid applications starting with JB, due to the app encryption), then this won't work because your app executable is not readable by others
Although hackbod finishes with 'readable by others' which suggests that if you are executing this through your own code, for your own application, it is readable? Please do correct me if you can test this and I'm wrong.
Conceivably you could just get the path to your .apk through Context.getApplicationInfo().sourceDir, and launch the app installer with that path. Not however if your app is forward locked (which is unavoidable for all paid applications starting with JB, due to the app encryption), then this won't work because your app executable is not readable by others. In that case you would need to copy the .apk to somewhere world readable (such as in external storage) and install it from there.
No matter what you do here, though, this has some unavoidable very negative consequences:
The only way to do any kind of install from your app is to go through the side-loading UI, which is (a) going to be a very scary experience for the user, and (b) will require that the user turn on side-loading to be able to proceed.
Installing your app this way will probably remove ownership of it from the Play Store (since it is no longer the one that has installed it). This may mean for example that the user can no longer report crashes or ANRs to you through the play store, or other negative consequences. I am not sure exactly what problems will actually happen here, but I really wouldn't assume that this is going to be okay.
Ultimately, I just would very much not suggest doing this. What permission are you needing that is forcing you to do this? For many reasons, I wouldn't recommend that third party applications declare their own permissions in most cases, because there are a lot of bad user experiences around permissions that are only known after they may have been needed.

Categories

Resources