Back to project page fooplayer-android.
The source code is released under:
GNU General Public License
If you think the Android project fooplayer-android 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 com.mauriciogiordano.fooplayer.database; // w w w. j ava2s . c o m import android.content.Context; import com.j256.ormlite.dao.Dao; import java.sql.SQLException; public class Bean<T> { protected Class<T> clazz; public Bean(Class<T> clazz) { this.clazz = clazz; } protected Dao<T, Integer> getDao(Context context) { Dao<T, Integer> dao = null; try { dao = DatabaseHelper.getInstance(context).getDao(clazz); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dao; } protected boolean save(Context context, T object) { Dao<T, Integer> dao = getDao(context); Dao.CreateOrUpdateStatus status; try { status = dao.createOrUpdate(object); return status.isCreated() || status.isUpdated(); } catch (SQLException e) { e.printStackTrace(); } return false; } }