Backing Up the Database Using adb

Let’s look at how to write to a SQLite application and how someone can pull the database off the phone. To begin, we need to add a SQLite database to the Android HelloWorld app. Listing 5-1 shows how to add a SQLite database to your Android app.

Listing 5-1 Adding SQLite to your code

package com.riis.sqlite3;import java.io.File;import android.os.Bundle;import android.app.Activity;import android.database.sqlite.SQLiteDatabase;                         // line 7public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.activity_main);          InitializeSQLite3();                                       // ...

Get Bulletproof Android™: Practical Advice for Building Secure Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.