Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/data/UserDB.java
- This file was moved from src/it/reyboz/bustorino/middleware/UserDB.java.
Show All 10 Lines | BusTO ("backend" components) | ||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU General Public License for more details. | GNU General Public License for more details. | ||||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino.middleware; | package it.reyboz.bustorino.data; | ||||
import android.content.ContentValues; | import android.content.ContentValues; | ||||
import android.database.Cursor; | import android.database.Cursor; | ||||
import android.database.sqlite.SQLiteDatabase; | import android.database.sqlite.SQLiteDatabase; | ||||
import android.database.sqlite.SQLiteException; | import android.database.sqlite.SQLiteException; | ||||
import android.database.sqlite.SQLiteOpenHelper; | import android.database.sqlite.SQLiteOpenHelper; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.util.Log; | import android.util.Log; | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | private void upgradeFromOldDatabase(SQLiteDatabase newdb) { | ||||
if(len2 < len) { | if(len2 < len) { | ||||
len = len2; | len = len2; | ||||
} | } | ||||
if (len > 0) { | if (len > 0) { | ||||
try { | try { | ||||
Stop stopStopStopStopStop; | |||||
for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
stopStopStopStopStop = new Stop(ID.get(i)); | final Stop mStop = new Stop(ID.get(i)); | ||||
stopStopStopStopStop.setStopUserName(username.get(i)); | mStop.setStopUserName(username.get(i)); | ||||
addOrUpdateStop(stopStopStopStopStop, newdb); | addOrUpdateStop(mStop, newdb); | ||||
} | } | ||||
} catch(Exception ignored) { | } catch(Exception ignored) { | ||||
// partial data is better than no data at all, no transactions here | // partial data is better than no data at all, no transactions here | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if(!OldDB.destroy(this.c)) { | if(!OldDB.destroy(this.c)) { | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { | ||||
public static boolean deleteStop(Stop s, SQLiteDatabase db) { | public static boolean deleteStop(Stop s, SQLiteDatabase db) { | ||||
try { | try { | ||||
db.delete(TABLE_NAME, "ID = ?", new String[]{s.ID}); | db.delete(TABLE_NAME, "ID = ?", new String[]{s.ID}); | ||||
return true; | return true; | ||||
} catch(SQLiteException e) { | } catch(SQLiteException e) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
public static boolean checkStopInFavorites(String stopID, Context con){ | |||||
boolean found = false; | |||||
// no stop no party | |||||
if (stopID != null) { | |||||
SQLiteDatabase userDB = new UserDB(con).getReadableDatabase(); | |||||
found = UserDB.isStopInFavorites(userDB, stopID); | |||||
} | |||||
return found; | |||||
} | |||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register