77bc28a35f615cd0f7ea9fbc675276b5f54e5b47
[JavaForFun] /
1 package name.gumartinm.weather.information.model;
2
3 import android.content.Context;
4
5 public class DatabaseQueries {
6         private final Context localContext;
7
8         public DatabaseQueries(final Context context) {
9                 this.localContext = context;
10         }
11         
12         public WeatherLocation queryDataBase() {
13         
14         final WeatherLocationDbHelper dbHelper = new WeatherLocationDbHelper(this.localContext);
15         try {
16                 final WeatherLocationDbQueries queryDb = new WeatherLocationDbQueries(dbHelper);        
17                 return queryDb.queryDataBase();
18         } finally {
19                 dbHelper.close();
20         } 
21     }
22     
23         public long insertIntoDataBase(final WeatherLocation weatherLocation) {
24         
25         final WeatherLocationDbHelper dbHelper = new WeatherLocationDbHelper(this.localContext);
26         try {
27                 final WeatherLocationDbQueries queryDb = new WeatherLocationDbQueries(dbHelper);        
28                 return queryDb.insertIntoDataBase(weatherLocation);
29         } finally {
30                 dbHelper.close();
31         } 
32     }
33     
34         public void updateDataBase(final WeatherLocation weatherLocation) {
35         
36         final WeatherLocationDbHelper dbHelper = new WeatherLocationDbHelper(this.localContext);
37         try {
38                 final WeatherLocationDbQueries queryDb = new WeatherLocationDbQueries(dbHelper);        
39                 queryDb.updateDataBase(weatherLocation);
40         } finally {
41                 dbHelper.close();
42         } 
43     }
44 }