Having a problem with my Android application. I currently have a CatDownloadService
which is suppose to do 2 things in the background:
I can't seem to decide between the various ways of achieving this. Can someone point me into the right direction? What I understand about each method is in the ().
Parse JSON
method in CatDownloadService (Since my JSON parsing would only be needed in this class)
parseCatJSON(jsonString);
method in CatJSONParser.java (Neater, since the logic for JSON parsing is in a class by itself)
CatJSONParser catJsonParser = new CatJSONParser(); catJsonParser.parseCatJSON(jsonString);
static method in CatJSONParser.java (Same as 2. Don't need object creation)
CatJSONParser.parseCatJSON(jsonString);
Add into database through DatabaseAccessObject
method in CatDatabaseAccessObject.java (Each context that uses the DBHelper is different)
CatDatabaseAccessObject catDAO = new CatDatabaseAccessObject(this); catDAO.addCat(cat);
static method in CatDatabaseAccessObject.java (Ensure there is only 1 connection to DB)
CatDatabaseAccessObject.addCat(cat);
Save Cat image to external storage
method in CatStorageManager.java
CatStorageManager catStorageManager = new CatStorageManager(); catStorageManager.writeCatImage(catInputStream);
static method in CatStorageManager.java
CatStorageManager.writeCatImage(catInputStream);
I'm really lost.
I categories static Method in two ways -
Harmful if they are keeping some misleading and unnecessary references.
public static InputStream is = null; public static void harfulStaticMethod(InputStream is) { BatteryManagerC.is = is; /* Read Content */ /* Leave open or is have used at multiple places */ }
Non Harmful only used to access method variables
public static void unharmFullStaticMethod(int a, int b) { int c = a + b; Log.e("Some Is=", String.valueOf(c)); }
As your question is broad and lead to many points. so its just reflect one View. Hope it help you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.