· 5 years ago · Nov 29, 2020, 03:24 PM
1package com.example.finalgroupproject;
2
3import android.content.Context;
4import android.database.SQLException;
5import android.database.sqlite.SQLiteDatabase;
6import android.database.sqlite.SQLiteException;
7import android.database.sqlite.SQLiteOpenHelper;
8import android.util.Log;
9
10import androidx.annotation.Nullable;
11
12import java.io.FileOutputStream;
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.OutputStream;
16import java.util.Locale;
17
18public class ALBUM_DATABASE extends SQLiteOpenHelper {
19 private static String XXXX = "";
20 private static final String DATABASE_PATH = "https://www.theaudiodb.com/api/v1/json/1/searchalbum.php?s=XXXX";
21 public final String ACTIVITY_NAME = "Audio Database api";
22 public final static String DATABASE_NAME = "Audio Database api";
23 public final static int VERSION_NUM = 2;
24 public final static String TABLE_NAME = "track";
25
26
27 public final static String ID_HEADER39 = "strAlbum";
28 public final static String ID_HEADER40 = "strArtist";
29 public final static String ID_HEADER50 = "strSong";
30 // public final static String ID_HEADER51 = "strLocked";
31
32 public boolean t = false;
33 public SQLiteDatabase db;
34
35 public ALBUM_DATABASE(Context context) {
36 super(context, DATABASE_NAME, null, VERSION_NUM);
37
38 }
39
40 @Override
41 public void onCreate(SQLiteDatabase db) {
42 db.execSQL("CREATE TABLE " + TABLE_NAME + " (_id INTEGER PRIMARY KEY AUTOINCREMENT, "
43 + ID_HEADER39 + " text,"
44 + ID_HEADER40 + " text,"
45 + ID_HEADER50 + " text);"); // add or remove columns
46 }
47
48 @Override
49 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
50 //Drop the old table:
51 db.execSQL( "DROP TABLE IF EXISTS " + TABLE_NAME);
52
53 //Create the new table:
54 onCreate(db);
55 }
56
57 @Override
58 public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
59 //Drop the old table:
60 db.execSQL( "DROP TABLE IF EXISTS " + TABLE_NAME);
61
62 //Create the new table:
63 onCreate(db);
64 }
65
66
67}