UpcApp.java
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.upc.pbe.upcnews;
import android.app.Application;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.util.Log;
public class UpcApp extends Application implements OnSharedPreferenceChangeListener {
final static String TAG = "Application";
private SharedPreferences prefs;
private String defaultUrl = "imanolbarba.myftp.biz/PBE";
private String url = null;
private String desc;
private final static String localPath = Environment.getExternalStorageDirectory().getPath() + "/UPC NEWS/";
public String getLocalPath()
{
return localPath;
}
public String getUrl() {
url = "http://" + prefs.getString("server", defaultUrl);
return url;
}
public void onCreate() {
super.onCreate();
//Prefs
prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
this.getUrl();
Log.d(TAG, "onCreated");
}
public SharedPreferences getPrefs() {
return prefs;
}
public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
Log.d(TAG, "onSharedPreferenceChanged for key: " + key);
}
public void setDesc(String s){
desc = s;
}
public String getDesc(){
return desc;
}
}