Back to project page Common-Alerting-Protocol-Compliant-Emergency-Warning-App-For-Android-Using-AMQP.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project Common-Alerting-Protocol-Compliant-Emergency-Warning-App-For-Android-Using-AMQP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package in.ac.iitd.cse.iuatc.ews; /*from w ww .jav a 2 s.c o m*/ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import android.content.Context; import android.database.Cursor; public class Utils { public static byte[] serialize(Object obj) throws IOException { ByteArrayOutputStream b = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(b); o.writeObject(obj); return b.toByteArray(); } public static Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException { ByteArrayInputStream b = new ByteArrayInputStream(bytes); ObjectInputStream o = new ObjectInputStream(b); return o.readObject(); } public static void getAlertsFromDataBase(Context context, ArrayList<SimpleAlert> alerts) { EwsApplication app = (EwsApplication)context.getApplicationContext(); Cursor cursor = app.getDataBaseHandler().getAll(); if (cursor.moveToFirst()) { do { try { alerts.add(0, (SimpleAlert)deserialize( cursor.getBlob( cursor.getColumnIndex(DataBaseHandler.KEY_CAP_BLOB)))); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } while (cursor.moveToNext()); } } }