Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 KB | None | 0 0
  1. Fatal Exception: java.lang.RuntimeException: Unable to create application com.StampWallet.StampwalletApp: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
  2. at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4715)
  3. at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(XposedBridge.java)
  4. at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
  5. at android.app.ActivityThread.handleBindApplication(<Xposed>)
  6. at android.app.ActivityThread.-wrap1(ActivityThread.java)
  7. at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
  8. at android.os.Handler.dispatchMessage(Handler.java:102)
  9. at android.os.Looper.loop(Looper.java:148)
  10. at android.app.ActivityThread.main(ActivityThread.java:5422)
  11. at java.lang.reflect.Method.invoke(Method.java)
  12. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  13. at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  14. at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
  15. Caused by android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
  16. at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
  17. at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
  18. at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
  19. at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
  20. at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
  21. at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
  22. at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
  23. at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
  24. at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
  25. at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:571)
  26. at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:269)
  27. at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
  28. at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
  29. at com.packageName.database.DatabaseManager.openDatabase(DatabaseManager.java:37)
  30. at com.packageName.MYApplicationFile.onCreate(StampwalletApp.java:210)
  31. at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
  32. at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4712)
  33. at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(XposedBridge.java)
  34. at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
  35. at android.app.ActivityThread.handleBindApplication(<Xposed>)
  36. at android.app.ActivityThread.-wrap1(ActivityThread.java)
  37. at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
  38. at android.os.Handler.dispatchMessage(Handler.java:102)
  39. at android.os.Looper.loop(Looper.java:148)
  40. at android.app.ActivityThread.main(ActivityThread.java:5422)
  41. at java.lang.reflect.Method.invoke(Method.java)
  42. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  43. at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  44. at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
  45.  
  46. @Override
  47. public void onCreate() {
  48. super.onCreate();
  49. //open database instance which will be used throughout application
  50. try {
  51. DatabaseManager.initializeInstance(new DatabaseHelper(this));
  52. DatabaseManager.getInstance().openDatabase();
  53. } catch (Exception e) {
  54. e.printStackTrace();
  55. }
  56.  
  57. }
  58.  
  59. @Override
  60. public void onTerminate() {
  61. //close database on terminate application
  62. DatabaseManager.getInstance().closeDatabase();
  63. super.onTerminate();
  64. }
  65.  
  66. public class DatabaseHelper extends SQLiteOpenHelper {
  67. // Database Name
  68. private static final String DATABASE_NAME = "MyDB";
  69. // Database Version
  70. private static final int DATABASE_VERSION = 25;
  71. private Context context;
  72.  
  73. public DatabaseHelper(Context context) {
  74. super(context, DATABASE_NAME, null, DATABASE_VERSION);
  75. this.context = context;
  76. }
  77.  
  78. @Override
  79. public void onCreate(SQLiteDatabase db) {
  80. // create table queries here
  81. }
  82.  
  83. @Override
  84. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  85. // upgrade table queries here
  86. }
  87.  
  88.  
  89.  
  90. }
  91.  
  92. public class DatabaseManager {
  93. private AtomicInteger mOpenCounter = new AtomicInteger();
  94.  
  95. private static DatabaseManager instance;
  96. //private static SQLiteOpenHelper mDatabaseHelper;
  97. private static DatabaseHelper mDatabaseHelper;
  98. private SQLiteDatabase mDatabase;
  99.  
  100. public static synchronized void initializeInstance(DatabaseHelper helper) {
  101. if (instance == null) {
  102. instance = new DatabaseManager();
  103. mDatabaseHelper = helper;
  104. }
  105. }
  106.  
  107. public static synchronized DatabaseManager getInstance() {
  108. if (instance == null) {
  109. throw new IllegalStateException(DatabaseManager.class.getSimpleName() +
  110. " is not initialized, call initializeInstance(..) method first.");
  111. }
  112.  
  113. return instance;
  114. }
  115.  
  116. public synchronized SQLiteDatabase openDatabase() {
  117. if (mOpenCounter.incrementAndGet() == 1) {
  118. // Opening new database
  119. mDatabase = mDatabaseHelper.getWritableDatabase();
  120. }
  121. return mDatabase;
  122. }
  123.  
  124. public synchronized void closeDatabase() {
  125. if (mOpenCounter.decrementAndGet() == 0) {
  126. // Closing database
  127. mDatabase.close();
  128. }
  129. }
  130.  
  131.  
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement