Android Tutorial SQL tutorial

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime 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
Longtime 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:
 

aklisiewicz

Active Member
Licensed User
Longtime 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 ?
 

eps

Expert
Licensed User
Longtime 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

  • themsc.zip
    1.2 KB · Views: 696

eps

Expert
Licensed User
Longtime 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

  • the_msc.zip
    355.9 KB · Views: 765

klaus

Expert
Licensed User
Longtime 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

  • the_msc_1.zip
    21.4 KB · Views: 705

eps

Expert
Licensed User
Longtime User
Okay, a really basic question...

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

klaus

Expert
Licensed User
Longtime 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

Expert
Licensed User
Longtime 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
Longtime 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....
 

schimanski

Well-Known Member
Licensed User
Longtime 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....
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…