This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |
Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); | |
if (newVersion > oldVersion) { // Upgrade | |
switch (oldVersion) { | |
case 1: | |
// Upgrade from version 1 to 2. | |
try { | |
Log.i(TAG, "upgrade 1->2: adding new column"); | |
db.execSQL("ALTER TABLE " + DATABASE_TABLE + " ADD COLUMN " + NEW_COLUMN + " INTEGER;"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String encryptCredentials(String plaintext) throws Exception { | |
String algorithm = "AES/CBC/PKCS5Padding"; | |
SecretKeySpec skeySpec = new SecretKeySpec(SECRET_KEY.getBytes(), algorithm); | |
Cipher cipher = Cipher.getInstance(algorithm); | |
cipher.init(Cipher.ENCRYPT_MODE, skeySpec); | |
byte[] encrypted = cipher.doFinal(plaintext.getBytes()); | |
return new String(encrypted); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String createShopSearchQuery() throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException { | |
String jsonAction = "http://api.ravelry.com/shops/search.json?"; | |
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSZ"); | |
Calendar now = Calendar.getInstance(); | |
String timestamp = df.format(now.getTime()); | |
String searchTerm = "yarn"; | |
int shop_type_id = 1; | |
String query = jsonAction; | |
query += "access_key=" + urlEncode(ACCESS_KEY); |