• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How do I set a schedule to automatically delete files using Android Studio?

ReiSixx9

Newbie
I want to add a command to my Android Studio app that will make it automatically delete files from a certain folder at a set interval. How do I do this?

Also, can I hide the folder (using a command) so that only my app can see it?

Sorry, I mostly only know stuff about c# and Windows Program Development, I'm new to this android stuff.

Thanks! :)
 
What command do I use to delete a certain folder then?

Also, can I hide the folder (using a command) so that only my app can see it?
 
What command do I use to delete a certain folder then?

http://stackoverflow.com/questions/5486529/delete-file-from-internal-storage
https://developer.android.com/reference/java/io/File.html


Also, can I hide the folder (using a command) so that only my app can see it?

All apps have an internal storage area, which is only accessible to that app.
External storage is different, and requires permission to read/write

https://developer.android.com/training/basics/data-storage/files.html
 
I can set the delete command to run at a certain interval (sorry my brain just totally forgot the word for that), correct?

So if I use internal storage somebody using the phone can't see the folder, but the app can use the data inside and send it via email or upload it to a cloud?
 
I can set the delete command to run at a certain interval (sorry my brain just totally forgot the word for that), correct?

Correct

So if I use internal storage somebody using the phone can't see the folder, but the app can use the data inside and send it via email or upload it to a cloud?

Your app's internal storage data can't be seen by any other app, but someone connecting to the device using ADB can see everything.
 
Also, where do I put the handler command? Like in the manifest or...?

I'm guessing this is the correct code, right?
Code:
final Handler handler = new Handler();
final Runnable r = new Runnable()
{
    public void run()
    {
        <some task>
    }
};
handler.postDelayed(r, 15000);
Or is it this?
Code:
 Handler handler = new Handler(Looper.getMainLooper());
        handler.postDelayed(new Runnable() {
            public void run() {
                AccelListener.this.timeout();
            }
        }, 2000);

Is there any part of this code that I need to customize (change to fit my specific program) besides the time?
 
Back
Top Bottom