DB file saving;

Put your problem here if it does not fit any of the other categories.

DB file saving;

Postby Alexandro » Thu Mar 05, 2009 5:50 pm

Hi there.
My problem is the following:

I have an url link to database.sql file
Getting input stream of it and saving it to a file:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. FileOutputStream out = context.openFileOutput(DB_FILE_NAME,
  3.  
  4.                 Context.MODE_PRIVATE);
  5.  
  6.             byte buf[]=new byte[1024];
  7.  
  8.             int len;
  9.  
  10.             while((len=is.read(buf))>0)
  11.  
  12.                 out.write(buf,0,len);
  13.  
  14.             out.flush();
  15.  
  16.             out.close();
  17.  
  18.             is.close();
  19.  
  20.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

("is" is initialized before)

And now i need to open this DB from my G1. i know that
context.openOrCreateDatabase() is used, but the problem is, that fileOutput saves it in /files directory and onCreateDB looking for DB's in /database directory.

How do I save in database directory (with PRIVATE mode if possible)?
Or maybe there is some other solution?
Alexandro
Junior Developer
Junior Developer
 
Posts: 24
Joined: Thu Mar 05, 2009 5:42 pm

Top

Postby MrSnowflake » Thu Mar 05, 2009 5:55 pm

Does it mather whether it's in files or databases? As long as opening it is working...
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Alexandro » Fri Mar 06, 2009 8:17 am

Edit:
Ok. I got it. I tried to open the database from Context.open but it doesn't support the path to file. Calling SQLiteDatabase.openOrCreate solved the problem.
Still, just curious, is there a possibility to save a file in /database folder? And is there any way to import .sql binary (not just saving it on the device)?
Alexandro
Junior Developer
Junior Developer
 
Posts: 24
Joined: Thu Mar 05, 2009 5:42 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 24 guests