I have several methods in the ListAC ListActivity that I want to reuse and would like to put in separate classes (if possible??). I will be having dozens of ListView Activities
Are there any similarities in the code of your extended SimpleCursorAdapter
? With regards to code like getting the external storage state, you could implement a class called, for example Utils
and make the methods within it static. You will more than likely need a Context
or Activity
passed as a parameter however.
For example this is my external storage state checker.
public static final boolean isExternalStorageAvailable() {
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
return true;
} else {
return false;
}
}
And my network state checker.
public static final boolean isPreferedNetworkAvailable(final Context context) {
final ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo networkInfo = connectivityManager.getNetworkInfo(connectivityManager.getNetworkPreference());
return networkInfo.isAvailable();
}