vendredi 17 avril 2015

android_studio VS eclipse

hi i wanted to create a database for my app in android studio but only the constructor of my SQLiteOpenHelper extended class is called in the activity i thought it was my problem but when i copy/paste the code in eclipse it worked perfectlyyyyy!!!!! and the on create method was called here is my SQLiteOpenHelper class:



public class TestHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAMEt = "testdatabase";
private static final int DATABASE_VERSION = 2;
private static final String TABLE_NAME = "SANATABLE";
private static final String UID="_id";
private static final String NAME="Name";
private static final String ADDRESS="Address";
private static final String CREATE_TABLE="CREATE TABLE "+TABLE_NAME+" ("+UID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+NAME+" VARCHAR(255), "
+ ADDRESS+" VARCHAR(255));";

private static final String DROP_TABLE="DROP TABLE"+TABLE_NAME+" IF EXISTS;";
private Context context;

public TestHelper(Context context) {
super(context, DATABASE_NAMEt, null, DATABASE_VERSION);
this.context=context;
messageBD.messageBD(context, "constructor called");
}
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(CREATE_TABLE);
messageBD.messageBD(context, "on create called");
Log.d("SANA", "on create called");
} catch (android.database.SQLException e) {
messageBD.messageBD(context,""+e);
Log.d("SANA", "error is" + e);
}


}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
try {
db.execSQL(DROP_TABLE);
onCreate(db);
messageBD.messageBD(context, "on upgrade called");
} catch (android.database.SQLException e) {
messageBD.messageBD(context,""+e);
}


}

}


the class messagebd contains only a toast to test things and my main activity got hello world statement only here it is:



public class TestBDactivity extends Activity {
TestHelper testHelper ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_bdactivity);
testHelper=new TestHelper(this);
SQLiteDatabase sqLiteDatabase= testHelper.getWritableDatabase();
}



}


and finally my logcat when i work with ANDROID STUDIO 1.0.1



4-17 16:00:08.979 647-844/com.android.exchange D/ExchangeService﹕ Received deviceId from Email app: null
04-17 16:00:08.979 647-844/com.android.exchange D/ExchangeService﹕ !!! deviceId unknown; stopping self and retrying
04-17 16:00:14.034 647-647/com.android.exchange D/ExchangeService﹕ !!! EAS ExchangeService, onStartCommand, startingUp = false, running = false
04-17 16:00:14.045 297-309/system_process W/ActivityManager﹕ Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
04-17 16:00:14.045 647-682/com.android.exchange D/ExchangeService﹕ !!! Email application not found; stopping self
04-17 16:00:14.074 647-647/com.android.exchange E/ActivityThread﹕ Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d1cd38 that was originally bound here
android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d1cd38 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
at android.app.ContextImpl.bindService(ContextImpl.java:1418)
at android.app.ContextImpl.bindService(ContextImpl.java:1407)
at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
04-17 16:00:14.084 297-436/system_process W/ActivityManager﹕ Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
04-17 16:00:14.104 647-647/com.android.exchange E/StrictMode﹕ null
android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d1cd38 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
at android.app.ContextImpl.bindService(ContextImpl.java:1418)
at android.app.ContextImpl.bindService(ContextImpl.java:1407)
at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
04-17 16:00:14.104 297-297/system_process W/ActivityManager﹕ Unbind failed: could not find connection for android.os.BinderProxy@410d0148

Aucun commentaire:

Enregistrer un commentaire