my code stock.com

Snippet options

Download: Download snippet as save-bd-to-sdcard.java.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

public void copyDatabaseToSdCard()
	{
		Log.e("Databasehealper", "********************************");
		try
		{
			File f1 = new File("data/data/com.coffeeandcookies.ushuaiamovil/databases/shopping_V3");
			if (f1.exists())
			{
				File f2 = new File(Environment.getExternalStorageDirectory().getAbsoluteFile() + "/shopping_V3.db");
				f2.createNewFile();
				InputStream in = new FileInputStream(f1);
				OutputStream out = new FileOutputStream(f2);
				byte[] buf = new byte[1024];
				int len;
				while ((len = in.read(buf)) > 0)
				{
					out.write(buf, 0, len);
				}
				in.close();
				out.close();
			}
		}
		catch (FileNotFoundException ex)
		{
			System.out.println(ex.getMessage() + " in the specified directory.");
			System.exit(0);
			ex.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
		Log.e("Databasehealper", "********************************");
	}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.