[android-developers] Re: What is the best way to backup app database to a file?

2009-09-20 Thread Moto

When doing:

//open your existing DB
InputStream dbStream = mContext.getAssets().open(yourDBName);

I'm not able to start reading...  Do I need a particular permission
type? Also, when writing back to that location a new database which
permission should be set?

Thanks,
-Moto!

On Sep 8, 12:37 pm, Moto medicalsou...@gmail.com wrote:
 Perfect!
 I really appreciate everyone's help!

 -Moto!

 On Sep 8, 1:05 am, mjc147 westmead...@yahoo.co.uk wrote:

  On Sep 7, 3:30 am, Mark Murphy mmur...@commonsware.com wrote:

   Now, the database path location may change in future Android releases,
   and I am not aware of a place in the API to get the path to a database
   in a more official fashion.

  You can use the Context.getDatabasePath() method:

 http://developer.android.com/reference/android/content/Context.html#g...)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-20 Thread Moto

I take that back...

It actually works without any permission as it should...

File f1 = ctx.getDatabasePath(appDatabase.db);
InputStream in = new FileInputStream(f1);

-Jona


On Sep 20, 2:19 pm, Moto medicalsou...@gmail.com wrote:
 When doing:

 //open your existing DB
 InputStream dbStream = mContext.getAssets().open(yourDBName);

 I'm not able to start reading...  Do I need a particular permission
 type? Also, when writing back to that location a new database which
 permission should be set?

 Thanks,
 -Moto!

 On Sep 8, 12:37 pm, Moto medicalsou...@gmail.com wrote:

  Perfect!
  I really appreciate everyone's help!

  -Moto!

  On Sep 8, 1:05 am, mjc147 westmead...@yahoo.co.uk wrote:

   On Sep 7, 3:30 am, Mark Murphy mmur...@commonsware.com wrote:

Now, the database path location may change in future Android releases,
and I am not aware of a place in the API to get the path to a database
in a more official fashion.

   You can use the Context.getDatabasePath() method:

  http://developer.android.com/reference/android/content/Context.html#g...)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-20 Thread Moto

I take that back...

It actually works without any permission as it should...

File f1 = ctx.getDatabasePath(appDatabase.db);
InputStream in = new FileInputStream(f1);

- Moto!

On Sep 20, 2:19 pm, Moto medicalsou...@gmail.com wrote:
 When doing:

 //open your existing DB
 InputStream dbStream = mContext.getAssets().open(yourDBName);

 I'm not able to start reading...  Do I need a particular permission
 type? Also, when writing back to that location a new database which
 permission should be set?

 Thanks,
 -Moto!

 On Sep 8, 12:37 pm, Moto medicalsou...@gmail.com wrote:

  Perfect!
  I really appreciate everyone's help!

  -Moto!

  On Sep 8, 1:05 am, mjc147 westmead...@yahoo.co.uk wrote:

   On Sep 7, 3:30 am, Mark Murphy mmur...@commonsware.com wrote:

Now, the database path location may change in future Android releases,
and I am not aware of a place in the API to get the path to a database
in a more official fashion.

   You can use the Context.getDatabasePath() method:

  http://developer.android.com/reference/android/content/Context.html#g...)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-08 Thread Moto

Perfect!
I really appreciate everyone's help!

-Moto!

On Sep 8, 1:05 am, mjc147 westmead...@yahoo.co.uk wrote:
 On Sep 7, 3:30 am, Mark Murphy mmur...@commonsware.com wrote:

  Now, the database path location may change in future Android releases,
  and I am not aware of a place in the API to get the path to a database
  in a more official fashion.

 You can use the Context.getDatabasePath() method:

 http://developer.android.com/reference/android/content/Context.html#g...)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-07 Thread mjc147

On Sep 7, 3:30 am, Mark Murphy mmur...@commonsware.com wrote:
 Now, the database path location may change in future Android releases,
 and I am not aware of a place in the API to get the path to a database
 in a more official fashion.

You can use the Context.getDatabasePath() method:

http://developer.android.com/reference/android/content/Context.html#getDatabasePath(java.lang.String)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-06 Thread Mark Murphy

Moto wrote:
 I need to somehow backup my applitcations database to a file so that
 it can later be retored using that file.  Any suggestions to doing
 this?

One approach is to copy the database file.

Tactically, new File(getFilesDir(), ../databases) is the directory
where your database file resides. Copy it using ordinary Java I/O,
though I recommend you not hold any open SQLiteDatabase objects on the
database at the time.

Now, the database path location may change in future Android releases,
and I am not aware of a place in the API to get the path to a database
in a more official fashion. Hence, you will need to double-check with
each Android release to confirm they have not moved the databases
someplace else.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Looking for Android opportunities? http://wiki.andmob.org/hado

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-06 Thread Moto

So, I can actually access the database as a file copy and than restore
it by moving it to the same location where it was copied from?

Thanks!

On Sep 6, 3:30 pm, Mark Murphy mmur...@commonsware.com wrote:
 Moto wrote:
  I need to somehow backup my applitcations database to a file so that
  it can later be retored using that file.  Any suggestions to doing
  this?

 One approach is to copy the database file.

 Tactically, new File(getFilesDir(), ../databases) is the directory
 where your database file resides. Copy it using ordinary Java I/O,
 though I recommend you not hold any open SQLiteDatabase objects on the
 database at the time.

 Now, the database path location may change in future Android releases,
 and I am not aware of a place in the API to get the path to a database
 in a more official fashion. Hence, you will need to double-check with
 each Android release to confirm they have not moved the databases
 someplace else.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Looking for Android opportunities?http://wiki.andmob.org/hado
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-06 Thread Mark Murphy

Moto wrote:
 So, I can actually access the database as a file copy and than restore
 it by moving it to the same location where it was copied from?

AFAIK, it should work fine, so long as it is your app doing the copying,
and you are not trying to use the database while copying (in either
direction).

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Looking for Android opportunities? http://wiki.andmob.org/hado

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-06 Thread Moto

Great this will be perfect!
Thanks Mark!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: What is the best way to backup app database to a file?

2009-09-06 Thread Roman ( T-Mobile USA)

Are you right now thinking only to backup your data base on the device
or also somewhere on a remote location (PC, server)?

You could easily do a byte copy of your DB

//open your existing DB
InputStream dbStream = mContext.getAssets().open(yourDBName);

OutputStream backupDbStream = new FileOutputStream(path+name of
your backup DB);

//copy file from your existing DB to your backup DB
byte[] buffer = new byte[1024];
int length;
while ((length = dbStream.read(buffer))0){
backupDbStream.write(buffer, 0, length);
}


If you want to support backing up the DB on a remote system, you could
easily use the same mechanism.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.




On Sep 6, 12:22 pm, Moto medicalsou...@gmail.com wrote:
 I need to somehow backup my applitcations database to a file so that
 it can later be retored using that file.  Any suggestions to doing
 this?

 The only way I would do it would be by reading every table to an xml
 ffile but it seems soo ineficient...  The data does not have to be
 humand readable...

 Thanks!
 -Moto!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---