変更されたバージョンを確認したい/ドロップボックスの共有リンクを含むテキスト ファイルのメタデータを取得したい。ユーザーが自分のアカウントを使用するようになるため、ドロップボックス API は使用しません。自分のアカウントにリンクしてもらいたいのですが、後でパスワードを変更する可能性があるため、手動でリンクすることはできません。
そのため、認証トークンはありません。ドロップボックスの共有リンクからメタデータを取得するだけで、バージョンの変更を確認し、バージョンが変更された場合は新しいファイルのコンテンツをダウンロードできます。
また、これを機能させるための他の提案も受け付けています。あなたの解決策を少し詳しく説明してください。
更新された E タグの問題:
public void getFromOnlineTxtDatabase(){
try{
URL url = new URL("url-here");
HttpURLConnection.setFollowRedirects(true);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(false);
con.setReadTimeout(20000);
con.setRequestProperty("Connection", "keep-alive");
//get etag for update check
String etag = con.getHeaderField("etag");
//String etag= "";
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0");
((HttpURLConnection) con).setRequestMethod("GET");
//System.out.println(con.getContentLength()) ;
con.setConnectTimeout(5000);
BufferedInputStream in = new BufferedInputStream(con.getInputStream());
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
System.out.println(responseCode);
}
StringBuffer buffer = new StringBuffer();
int chars_read;
//int total = 0;
while ((chars_read = in.read()) != -1)
{
char g = (char) chars_read;
buffer.append(g);
}
final String page = buffer.toString();
//create password_ems.txt to internal
if (fileExistance("data.txt")){
File dir = getFilesDir();
File file = new File(dir, "data.txt");
boolean deleted = file.delete();
stringToTxt(page, "data.txt");
}else{
stringToTxt(page, "data.txt");
}
if (fileExistance("data_etag.txt")){
File dir = getFilesDir();
File file = new File(dir, "etag.txt");
boolean deleted = file.delete();
stringToTxt(etag, "etag.txt");
}else{
//create etag_file
stringToTxt(etag, "data_etag.txt");
}
// Log.i("Page", page);
}catch(Exception e){
showDialog("Database Fetch Failure","Unable to Fetch Password Database, check your internet" +
" connection and try again later.",0);
Log.i("Page", "Error");
}
}