Is it possible to delete the download folder using java code?

I am wondering if there is a way to delete a folder inside res in an android app via java code in action.

Imagine I have some files in drawable-nodpi in paid applications that have "license check" or "payment check". I want that if this "license" is invalid, it will delete the files inside (drawable-nodpi) and only this folder using some lines of code in my activity.

Thanks in advance for any help or information.

+3


source to share


3 answers


I am wondering if there is a way to delete a folder inside res in an android app via java code in action.



Not. Resources and resources are read-only at runtime.

+3


source


The quick answer is no.

For your problem, however, you can simply stop showing the drawings in the application. This would be very easy to do. The selected ones will still be in the folder res/drawable

, but they will no longer be displayed.



Another thing you can do is download these files at runtime after checking the license, but this solution will require more work on your part.

0


source


Yes it is possible, however what you should consider is how the real Android OS security works.

Consider the following: On standard (non-root) devices, Android security relies heavily on the linux user / group system, which states that you can only have certain permissions if you belong to a user group that a certain kind of access belongs to.

Android applications own their "own" user and therefore cannot access another file or process that may be owned by anything else.

If you want to delete specific directories, files, etc. with java code, you will need to become root or use an engineering build of your specific android distribution and grant access to your application by changing it to the root of the user group.

Finally, consider whether Android should work this way? The answer is no, as it would be an exploitative violation on the system, allowing applications to perform such tasks.

-1


source







All Articles