Sub Process_Globals
Public Image As Bitmap 'public image
Private SQL1 As SQL 'private sql object
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Image = LoadBitmap(File.DirAssets, "Image.jpg")
SQL1.Initialize(File.DirInternal, "1.db", True)
End If
End Sub
we should not store an private variable on Process_Global because this sub is for public variables which we want to be accessable from another activity
B4X:
Public Sql1 as SQL
IS Correct i think
and also i think we should not store an ui element on process_global because it will be kept alive when the activity is recreated and maybe be a reason for memory leak
we should not store an private variable on Process_Global because this sub is for public variables which we want to be accessable from another activity
ActuallySQL objects should always be declared as process global variables.
It is also completely fine to declare it a private variable.
Bitmaps are not "activity objects". It is better to declare them as process global variables.
It really depends on your app requirements. In most cases it is better not to leave any file on the device after your app is uninstalled. Also note that File.DirDefaultExternal folder will also be cleaned when your app is uninstalled.
This again depends on the requirements. If the SQL object will only be used in the current activity then it is better to declare it as a private variable.
Hint: The image will be used from other activities as well.
ActuallySQL objects should always be declared as process global variables.
It is also completely fine to declare it a private variable.
Bitmaps are not "activity objects". It is better to declare them as process global variables.
It really depends on your app requirements. In most cases it is better not to leave any file on the device after your app is uninstalled. Also note that File.DirDefaultExternal folder will also be cleaned when your app is uninstalled.
LoadBitmap is identical to Bitmap.Initialize.
This again depends on the requirements. If the SQL object will only be used in the current activity then it is better to declare it as a private variable.
Hint: The image will be used from other activities as well.
....if running the code from Erel, there will be no error on my nexus, there is only this wonderfull app, doing nothing beside creating and opening a database and an image....mmmhhhh....
if running the code from Erel, there will be no error on my nexus, there is only this wonderfull app, doing nothing beside creating and opening a database and an image
This is exactly the problem with this bug. It will almost never reveal itself during development. However it will easily crash your app when it runs on the users phone.
Let me repeat the hint I posted:
The image (as Main.Image) will be used from other activities as well.