Created
March 20, 2014 00:23
-
-
Save jacksonfdam/9654717 to your computer and use it in GitHub Desktop.
Usando ACRA e ActiveRecordBase
This file contains 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
package com.coderockr.testeandroid.jacksonfdam; | |
import org.acra.ACRA; | |
import org.acra.ReportingInteractionMode; | |
import org.acra.annotation.ReportsCrashes; | |
import org.kroz.activerecord.ActiveRecordBase; | |
import org.kroz.activerecord.ActiveRecordException; | |
import org.kroz.activerecord.Database; | |
import org.kroz.activerecord.DatabaseBuilder; | |
import android.app.Application; | |
import android.content.SharedPreferences; | |
import android.preference.PreferenceManager; | |
import android.util.Log; | |
import com.coderockr.testeandroid.jacksonfdam.dao.Brand; | |
import com.coderockr.testeandroid.jacksonfdam.dao.Product; | |
@ReportsCrashes(formKey = "dGVacG0ydVHnaNHjRjVTUTEtb3FPWGc6MQ", formUri = "http://www.jacksonfdam.com/reports/", mode = ReportingInteractionMode.TOAST, resToastText = R.string.crash_toast_text) | |
public class CatalogoApp extends Application { | |
private static final String LOG_TAG = CatalogoApp.class.getSimpleName(); | |
public ActiveRecordBase mDatabase; | |
private static CatalogoApp instance = null; | |
private SharedPreferences settings; | |
private static void checkInstance() { | |
if (instance == null) | |
throw new IllegalStateException("A aplicacao nao foi criada ainda!"); | |
} | |
public static CatalogoApp getInstance() { | |
checkInstance(); | |
return instance; | |
} | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
Log.d("Despesas", "Iniciando APP Catalogo"); | |
instance = this; | |
// Device model | |
String PhoneModel = android.os.Build.MODEL; | |
// Android version | |
String AndroidVersion = android.os.Build.VERSION.RELEASE; | |
System.out.println("Detalhes --> PhoneModel " + PhoneModel + " - AndroidVersion " + AndroidVersion); | |
DatabaseBuilder builder = new DatabaseBuilder("catalogoapp.db"); | |
builder.addClass(Brand.class); | |
builder.addClass(Product.class); | |
Database.setBuilder(builder); | |
try { | |
mDatabase = ActiveRecordBase.open(this, "catalogoapp.db", 3); | |
} catch (ActiveRecordException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
settings = PreferenceManager.getDefaultSharedPreferences(this); | |
ACRA.init(this); | |
} | |
public ActiveRecordBase getDatabase() { | |
return mDatabase; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment