0

I'm trying to make an app that automatic download the newest file from a website and put it in a folder, from witch i can acces it. The problem is that accessing this website requires a login/password. How do i get these informations the first time i run the app, and the automaticly acces the website to see whether a new file has to be downloaded, when i click an update-button? Any material, tutorials etc. will help. I don't know where to look for this stuff.

Best regards Jesper

gedemagt
  • 657
  • 1
  • 9
  • 22

1 Answers1

1

This isn't a very simple question to answer because it's so broad and involves several different operations.

User Credentials

  1. On startup you need to check some sort of storage (e.g: SharedPreferences, Database) for a username/password.

  2. If none exists, you'll need to prompt the user to enter their username/password so you can capture and store it somewhere (e.g: SharedPreferences, Database)

Shared Preferences Tutorial

Database Tutorial

File Updates

File Modified Date - Before deciding whether or not to download the file, you need to know when it was modified. This should help: Android: how to know file located in web server is modified?

Determine if the file is newer - After you get the last modified date of the file on the server, you need to compare it to the modified date of the file you currently have. I would suggest that whenever you download a file, you save the modified date (retrieved above) in some sort of persistant storage (Database, SharedPref).

Downloading the File - Here's a tutorial that should help if you decide you need to download the file on the server. http://www.hassanpur.com/blog/2011/04/android-development-downloading-a-file-from-the-web/ - A bit complicated, but it also does the download on a background thread, which is a good idea.

Pretty vague answer, I know, but it was a pretty broad question. If you have a more specific question, we can give you a better answer.

Community
  • 1
  • 1
Gophermofur
  • 2,101
  • 1
  • 14
  • 14