Other [quiz] Find the bug

Erel

B4X founder
Staff member
Licensed User
Longtime User
Last edited:

imbault

Well-Known Member
Licensed User
Longtime User
First DirInternal is not the place I would put the DB, it could be deleted in case of uninstall... I would use File.DirDefaultExternal

I don't know it's a really a bug, but I should load the image file with a Initialize, like this
B4X:
Image.Initialize(File.DirAssets, "Image.jpg")

And Scope of SQL1 to be private, will exclude it from others modules..., so I would put it Public
 
Upvote 0

ArminKH

Well-Known Member
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
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
We are not there yet...

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.

First DirInternal is not the place I would put the DB, it could be deleted in case of uninstall... I would use File.DirDefaultExternal
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.

And Scope of SQL1 to be private, will exclude it from others modules..., so I would put it Public
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.
 
Upvote 0

ArminKH

Well-Known Member
We are not there yet...


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.
so maybe we should use LoadBitmapSample instead LoadBitmap?I'm not sure exactly this can be a bug or not
 
Upvote 0

ArminKH

Well-Known Member
wasn't there a limitation that some things only worked with lower cased filenames?
no i test it with upercase name and still works
maybe the bug be in Initialize and is related to Activity LifeCycle
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
I am missing the file copy from File.DirAssets to File.DirInternal:
B4X:
File.Copy(File.DirAssets,"1.db", File.DirInternal,"1.db")
 
Upvote 0

ArminKH

Well-Known Member
I am missing the file copy from File.DirAssets to File.DirInternal:
B4X:
File.Copy(File.DirAssets,"1.db", File.DirInternal,"1.db")
no,then a new database will be created if it dosn't exist any database named 1.db on DirInternal and if CreateIsNecessary is true
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I don't have a 5.x device but on 2.x-4. file.dirinternal was read only, not? so that would lead to an init error.
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
....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....:confused:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
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.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I just copied it to a project aswell, no errors and the image displayed fine.
 
Upvote 0
Top