Android Tutorial SQL tutorial

Status
Not open for further replies.

Erel

Administrator
Staff member
Licensed User
Seems like your emulator is not able to access the SD card. You should create a new emulator instance and make sure to set enough space for the SD card.

Please try to run the following code:
B4X:
    Msgbox(File.ExternalWritable, "")
    File.WriteString(File.DirRootExternal, "1.txt", "asdasdasdasd")
It should display a message box with true or false depending on the external storage availability. It will also try to create a text file.
 

a_carignan

Member
Licensed User
I have to create the order
sql1.ExecnonQuery("vacuum")
but at the time of l' execution it marks a error; writing/Reading on the disc.
:sign0163:
 

Erel

Administrator
Staff member
Licensed User
Android doesn't support full database encryption. You will need to manually encrypt the data.
 

aklisiewicz

Active Member
Licensed User
so far not to well...

I'm just trying to run this code and all I get is a happy face. Tapping on BACK button closes App. This happens on device and the emulator as well.
Any idea ?
 

Erel

Administrator
Staff member
Licensed User
This is the expected behavior. It should also write log messages which you can see in the Logs tab at the right pane.
 

eps

Well-Known Member
Licensed User
Nope! I just can't make this work!! :sign0104:

I think I've got it to succesfully find the database file, but then it just won't find the tables... I did go over the stuff that was posted about a metadata table and _id..

Any ideas?

I get :

android.database.sqlite.SQLiteException: no such table: favourite: , while compiling: SELECT count(*) FROM favourite

Code is :

Cursor = SQL1.ExecQuery("SELECT count(*) FROM favourite")

I've defined Cursor :

Sub Globals
Dim TabHost1 As TabHost
Dim txtName, txtAnimal, txtColor As EditText
Dim ListView1 As ListView
Dim Label1 As Label
Dim btnNext1 As Button
Dim Cursor As Cursor

DB file attached..

I get the same error if I try to access the other table, event..

hmm... I'm obviously doing something wrong or have missed something but not sure what! :sign0085:
 

Attachments

klaus

Expert
Licensed User
I would suggest you to post your whole project so we could look where the problem is.

Best regards.
 

eps

Well-Known Member
Licensed User
Certainly. Files attached, although of course they're a WIP... :)

I think that it's "something" to do with the database structure/file tho... but I am a :sign0104:
 

Attachments

klaus

Expert
Licensed User
Are you shure that your db file is in the File.DirInternal ?
In the attached program the de file is copied from File.DirAssets to File.DirInternal if it doesn't exist.
Acces to events works.

Best regards.
 

Attachments

eps

Well-Known Member
Licensed User
Okay, a really basic question...

What is the actual difference between File.DirAssets and File.DirInternal?
 

klaus

Expert
Licensed User
File.DirAssets
The assets folder includes the files that were added with the file manager. These files are read-only. You can not create new files in this folder (which is actually located inside the apk file).

File.DirInternal / File.DirInternalCache
These two folders are stored in the main memory and are private to your application. Other applications cannot access these files.
The cache folder may get deleted by the OS if it needs more space.

Have a look here.

Best regards.
 

eps

Well-Known Member
Licensed User
Klaus

That's excellent, thanks for that. Is this supposed to work in the emulator? I'm guessing not... Which is probably the source of my error.

Hmm... I didn't have an "SD card installed" but I guess that's not the problem either.. but something along these lines.. i.e. I haven't got
the emulator set up properly to allow me to copy the file.. or will it never work in the emulator?

Duh, yep, I guess I hadn't set the emulator up with any storage capabilities...

All good now :)
 
Last edited:

schimanski

Well-Known Member
Licensed User
Storing maptiles in an sql-database

Hello!

I have still no experience with working with sql. So I need a sound rating, before I read several hours about it: Is it perhaps possible to strore maptiles (.png) in an sql-database? I'm still working with normal .png-files in my offline mapviewer, but there are several problems by working with thousands of these files. It takes several hours to copy it to trhe SD-card and by wrong cluster-format, the tiles get to much space on the card.
My idea is, to collect every zoomlevel in one database. But is it possible to fill the database up to more than 2 or 3 GB. And is it fast enough for display the tiles out of the database on the screen?

Thanks for your help....
 

Erel

Administrator
Staff member
Licensed User
It is possible to store any binary data in the database using blobs. I think that the example in the first post includes such a feature.

I do not know how it will perform. I guess that it will perform fine, however I recommend you to create a small test first.
 

schimanski

Well-Known Member
Licensed User
Thanks, Erel for your efforts!

It is possible to download maptiles in ready sqlite-databases with the Desktop-application Mobile Atlas Creator, for example. I have downloaded such a database with a few maptiles in the OruxMaps SQlite-format. My question ist know, is it possible to get the tiles out of these database? I'm not sure, how to check the structure of these database...

Thanks for any help....
 

Erel

Administrator
Staff member
Licensed User
There are many applications that allow you to browse SQLite databases. Try opening this db with one and check its structure.
 
Status
Not open for further replies.
Top