Android Tutorial SQL tutorial

Discussion in 'Tutorials & Examples' started by Erel, Dec 2, 2010.

Thread Status:
Not open for further replies.
  1. HankAllen

    HankAllen New Member Licensed User

    Emulator

    Yes, it was in the emulator.
     
  2. Erel

    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:
    Code:
    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.
     
  3. a_carignan

    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:
     
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. critalsoft

    critalsoft Member Licensed User

  6. Erel

    Erel Administrator Staff Member Licensed User

    Android doesn't support full database encryption. You will need to manually encrypt the data.
     
  7. aklisiewicz

    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 ?
     
  8. Erel

    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.
     
  9. eps

    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:
     

    Attached Files:

  10. klaus

    klaus Expert Licensed User

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

    Best regards.
     
  11. eps

    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:
     

    Attached Files:

  12. klaus

    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.
     

    Attached Files:

  13. eps

    eps Well-Known Member Licensed User

    Okay, a really basic question...

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

    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.
     
  15. eps

    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: May 31, 2011
  16. eps

    eps Well-Known Member Licensed User

    yipeeeeeeeeeeeeee! :)

    :wav:
     
  17. schimanski

    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....
     
  18. Erel

    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.
     
  19. schimanski

    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....
     
  20. Erel

    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.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice