Database Help

OK so I am making an app that has videos listed out and then when you tap one it plays. The problem i'm having is that i cant figure out how to add the videos to the database and them list out once, because on the sample it had the 3 items list out over and over again when you re-launched the simulator. Also i was wondering if i could set this up on like a file hostings site such as dropbox.com and have the database file there considering i will most likely be using this on my phone.

Thanks.

Can anyone help me? I still have not figured it out.

Do you have a code sample? It's not clear what sort of DB you're using or how you are generating the list. (ie: is this an SQlite problem, or a LUA problem?)

Hmm probably a SQlite problem because calling the files and data fro the DB seem to be easy, i just dont know how to get the files into the database so that they can be called. Also i dont really have a code except for the version provided in the sample:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
-- Add onscreen text
local label1 = display.newText( "SQLite demo", 20, 30, native.systemFontBold, 20 )
label1:setTextColor( 190, 190, 255 )
local label2 = display.newText( "Creates or opens a local database", 20, 50, native.systemFont, 14 )
label2:setTextColor( 190, 190, 255 )
local label3 = display.newText( "(Data is shown below)", 20, 90, native.systemFont, 14 )
label3:setTextColor( 255, 255, 190 )
 
--Include sqlite
require "sqlite3"
--Open data.db.  If the file doesn't exist it will be created
local path = system.pathForFile("data.db", system.DocumentsDirectory)
db = sqlite3.open( path )   
 
--Handle the applicationExit event to close the db
local function onSystemEvent( event )
        if( event.type == "applicationExit" ) then              
            db:close()
        end
end
 
--Setup the table if it doesn't exist
local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content, content2);]]
print(tablesetup)
db:exec( tablesetup )
 
--Add rows with a auto index in 'id'. You don't need to specify a set of values because we're populating all of them
local testvalue = {}
testvalue[1] = 'Hello'
testvalue[2] = 'World'
testvalue[3] = 'Lua'
local tablefill =[[INSERT INTO test VALUES (NULL, ']]..testvalue[1]..[[',']]..testvalue[2]..[['); ]]
local tablefill2 =[[INSERT INTO test VALUES (NULL, ']]..testvalue[2]..[[',']]..testvalue[1]..[['); ]]
local tablefill3 =[[INSERT INTO test VALUES (NULL, ']]..testvalue[1]..[[',']]..testvalue[3]..[['); ]]
db:exec( tablefill )
db:exec( tablefill2 )
db:exec( tablefill3 )
 
--print the sqlite version to the terminal
print( "version " .. sqlite3.version() )
 
--print all the table contents
for row in db:nrows("SELECT * FROM test") do
  local text = row.content.." "..row.content2
  local t = display.newText(text, 20, 120 + (20 * row.id), native.systemFont, 16)
  t:setTextColor(255,0,255)
end
 
--setup the system listener to catch applicationExit
Runtime:addEventListener( "system", onSystemEvent )

I don't know if Corona supports video playback, but if it does you could upload your videos to some website and insert the URL in the database, then play the video from that URL. That's how I would insert videos into the db

Hmm ok thank you. But do you know how to automatically update the app with new videos? And if i could just put the DB on a site and then put the files in there?

views:1713 update:2012/1/9 8:53:30
corona forums © 2003-2011