-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
8u31
-
x86
-
windows_8
FULL PRODUCT VERSION :
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Jon>java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
C:\Users\Jon>
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Jon>java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Android Studio 1.0.2
A DESCRIPTION OF THE PROBLEM :
Singleton pattern does not appear to be possible to implement, in Android Studio, and, although this might be a restriction with the software, perhaps one can think of a workaround to make the life easier for Java developers.
REGRESSION. Last worked in version 8u31
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.example.jon.myapplication;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by Jon on 16/02/2015.
*/
public class SQLiteHelper extends SQLiteOpenHelper {
public SQLiteHelper getInstance()
{
if (instance !=null ) {instance = new SQLiteHelper();}
}
@Override
public String getDatabaseName()
{
return(super.getDatabaseName());
}
@Override
public SQLiteDatabase getReadableDatabase()
{
db = super.getReadableDatabase();
return db;
}
@Override
public SQLiteDatabase getWritableDatabase()
{
db = super.getWritableDatabase();
return db;
}
@Override
public void onConfigure (SQLiteDatabase db)
{
//TODO write event handling code
}
@Override
public void onCreate (SQLiteDatabase db)
{
//TODO write event handling code
}
public void onDowngrade (SQLiteDatabase db)
{
//TODO write event handling code
}
@Override
public void onOpen (SQLiteDatabase db)
{
//TODO write event handling code
}
public void onUpgrade (SQLiteDatabase db, int oldVersion, int NewVersion)
{
//TODO add logic for this as there is some studying to do :(
/* if (newVersion > oldVersion) {
db.execSQL(" IF NOT EXISTS CREATE TABLE version-control ADD COLUMN field1 TEXT," +
"ADD COLUMN field2 TEXT," +
"ADD COLUMN field3 TEXT," +
"ADD COLUMN field4 TEXT");
Sourced from an online article at http://stackoverflow.com/questions/26076139/android-sqlite-onupgrade-create-new-table */
//TODO revise event handling code
}
public void setWriteAheadLoggingEnabled (boolean WALIsEnabled)
{
this.WALIsEnabled = WALIsEnabled;
}
private SQLiteDatabase db;
private boolean WALIsEnabled = true;
private SQLiteHelder instance;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None available to date
I also reported this issue at https://code.google.com/p/android/issue.
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Jon>java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
C:\Users\Jon>
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Jon>java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Android Studio 1.0.2
A DESCRIPTION OF THE PROBLEM :
Singleton pattern does not appear to be possible to implement, in Android Studio, and, although this might be a restriction with the software, perhaps one can think of a workaround to make the life easier for Java developers.
REGRESSION. Last worked in version 8u31
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.example.jon.myapplication;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by Jon on 16/02/2015.
*/
public class SQLiteHelper extends SQLiteOpenHelper {
public SQLiteHelper getInstance()
{
if (instance !=null ) {instance = new SQLiteHelper();}
}
@Override
public String getDatabaseName()
{
return(super.getDatabaseName());
}
@Override
public SQLiteDatabase getReadableDatabase()
{
db = super.getReadableDatabase();
return db;
}
@Override
public SQLiteDatabase getWritableDatabase()
{
db = super.getWritableDatabase();
return db;
}
@Override
public void onConfigure (SQLiteDatabase db)
{
//TODO write event handling code
}
@Override
public void onCreate (SQLiteDatabase db)
{
//TODO write event handling code
}
public void onDowngrade (SQLiteDatabase db)
{
//TODO write event handling code
}
@Override
public void onOpen (SQLiteDatabase db)
{
//TODO write event handling code
}
public void onUpgrade (SQLiteDatabase db, int oldVersion, int NewVersion)
{
//TODO add logic for this as there is some studying to do :(
/* if (newVersion > oldVersion) {
db.execSQL(" IF NOT EXISTS CREATE TABLE version-control ADD COLUMN field1 TEXT," +
"ADD COLUMN field2 TEXT," +
"ADD COLUMN field3 TEXT," +
"ADD COLUMN field4 TEXT");
Sourced from an online article at http://stackoverflow.com/questions/26076139/android-sqlite-onupgrade-create-new-table */
//TODO revise event handling code
}
public void setWriteAheadLoggingEnabled (boolean WALIsEnabled)
{
this.WALIsEnabled = WALIsEnabled;
}
private SQLiteDatabase db;
private boolean WALIsEnabled = true;
private SQLiteHelder instance;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None available to date
I also reported this issue at https://code.google.com/p/android/issue.