When installing my application on an Android device, the database file is stored in the root folder of the SD card. But it should be placed on the path <SD Card_Root>\<Project_Name>\<dbfile>
. After removing the application from the device, the database file, including the project folder, should also be deleted. So, please help me solve two problems as below:
1. After installing the apk file on the device, the database file should be placed in the path <SD Card_Root>\<Project_Name>\<dbfile>
. 2. After deleting the apk file, the database file containing the root folder should be deleted automatically.
Please help me with your ideas / links.
Here is my code:
import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import android.os.Environment; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; public class DataBaseHelper extends SQLiteOpenHelper{ private static String DB_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() ; private static String DB_NAME = "Database.db"; private SQLiteDatabase myDataBase; private final Context myContext; public DataBaseHelper(Context context) { super(context, DB_NAME, null, 2); this.myContext = context; } public void createDataBase() throws IOException {
}
source share