project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/Utils.java
equal
deleted
inserted
replaced
26 import java.io.InputStream; |
26 import java.io.InputStream; |
27 import java.util.ArrayList; |
27 import java.util.ArrayList; |
28 |
28 |
29 import android.content.Context; |
29 import android.content.Context; |
30 import android.content.res.TypedArray; |
30 import android.content.res.TypedArray; |
|
31 import android.os.Build; |
|
32 import android.os.Environment; |
31 import android.widget.Toast; |
33 import android.widget.Toast; |
32 |
34 |
33 public class Utils { |
35 public class Utils { |
34 |
36 |
35 |
37 |
37 * get the path to which we should download all the data files |
39 * get the path to which we should download all the data files |
38 * @param c context |
40 * @param c context |
39 * @return absolute path |
41 * @return absolute path |
40 */ |
42 */ |
41 public static String getDownloadPath(Context c){ |
43 public static String getDownloadPath(Context c){ |
42 File f = c.getExternalCacheDir(); |
44 if(Build.VERSION.SDK_INT < 8){//8 == Build.VERSION_CODES.FROYO |
43 if(f != null){ |
45 return PreFroyoSDCardDir.getDownloadPath(c); |
44 return f.getAbsolutePath() + "/Data/"; |
|
45 }else{ |
46 }else{ |
46 Toast.makeText(c, R.string.sdcard_not_mounted, Toast.LENGTH_LONG); |
47 return FroyoSDCardDir.getDownloadPath(c); |
|
48 } |
|
49 } |
|
50 |
|
51 static class FroyoSDCardDir{ |
|
52 public static String getDownloadPath(Context c){ |
|
53 File f = c.getExternalCacheDir(); |
|
54 if(f != null){ |
|
55 return f.getAbsolutePath() + "/Data/"; |
|
56 }else{ |
|
57 Toast.makeText(c, R.string.sdcard_not_mounted, Toast.LENGTH_LONG).show(); |
|
58 return null; |
|
59 } |
|
60 } |
|
61 } |
|
62 |
|
63 static class PreFroyoSDCardDir{ |
|
64 public static String getDownloadPath(Context c){ |
|
65 if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ |
|
66 if(Environment.getExternalStorageDirectory() != null) |
|
67 return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Hedgewars/"; |
|
68 } |
|
69 Toast.makeText(c, R.string.sdcard_not_mounted, Toast.LENGTH_LONG).show(); |
47 return null; |
70 return null; |
48 } |
71 } |
49 } |
72 } |
50 |
73 |
51 /** |
74 /** |