Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid static method vs object creation
    primarykey
    data
    text
    <p>Having a problem with my Android application. I currently have a <code>CatDownloadService</code> which is suppose to do 2 things in the background:</p> <ol> <li>Download the information of the cat (id, name, imageid, etc...) from the server as JSON</li> <li>Parse the JSON into an Cat object</li> <li>Insert the Cat object into the database through a CatDatabaseAccessObject</li> <li>Download image of cat</li> <li>Save image onto external storage.</li> </ol> <p>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 ().</p> <p><strong>Parse JSON</strong></p> <ol> <li><p>method in CatDownloadService (Since my JSON parsing would only be needed in this class)</p> <pre><code>parseCatJSON(jsonString); </code></pre></li> <li><p>method in CatJSONParser.java (Neater, since the logic for JSON parsing is in a class by itself)</p> <pre><code>CatJSONParser catJsonParser = new CatJSONParser(); catJsonParser.parseCatJSON(jsonString); </code></pre></li> <li><p>static method in CatJSONParser.java (Same as 2. Don't need object creation)</p> <pre><code>CatJSONParser.parseCatJSON(jsonString); </code></pre></li> </ol> <p><strong>Add into database through DatabaseAccessObject</strong></p> <ol> <li><p>method in CatDatabaseAccessObject.java (Each context that uses the DBHelper is different)</p> <pre><code>CatDatabaseAccessObject catDAO = new CatDatabaseAccessObject(this); catDAO.addCat(cat); </code></pre></li> <li><p>static method in CatDatabaseAccessObject.java (Ensure there is only 1 connection to DB)</p> <pre><code>CatDatabaseAccessObject.addCat(cat); </code></pre></li> </ol> <p><strong>Save Cat image to external storage</strong></p> <ol> <li><p>method in CatStorageManager.java</p> <pre><code>CatStorageManager catStorageManager = new CatStorageManager(); catStorageManager.writeCatImage(catInputStream); </code></pre></li> <li><p>static method in CatStorageManager.java</p> <pre><code>CatStorageManager.writeCatImage(catInputStream); </code></pre></li> </ol> <p>I'm really lost.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload