The database data is not updated in the applicationShip an application with a databaseIs quitting an application frowned upon?How do I pass data between Activities in Android application?Android database recreates every time application is launchedAndroid SQL Database - rawQuery() Source not FoundWhy does my exception handler not trap Android SQLite insert error?Cursor for database on sdcard not closing or deactiveUse prepopulated SQLite database in android while using exisntent android APISqlite Join errorRoom Android - How to handle database version upgrade

How does mmorpg store data?

Rear derailleur got caught in the spokes, what could be a root cause

How can an inexperienced GM keep a game fun for experienced players?

"I am [the / an] owner of a bookstore"?

Is this house-rule removing the increased effect of cantrips at higher character levels balanced?

Is it OK to throw pebbles and stones in streams, waterfalls, ponds, etc.?

Having to constantly redo everything because I don't know how to do it

Early 2000s movie about time travel, protagonist travels back to save girlfriend, then into multiple points in future

How do I keep a running total of data in a column in Excel?

Checkmate in 1 on a Tangled Board

How did they film the Invisible Man being invisible in 1933?

How to track mail undetectably?

Why should I allow multiple IPs on a website for a single session?

Does a lens with a bigger max. aperture focus faster than a lens with a smaller max. aperture?

What was the point of separating stdout and stderr?

How soon after takeoff can you recline your airplane seat?

Does it make sense to (partially) create a conlang that you don't intend to actually use in the story?

How do I tell my girlfriend she's been buying me books by the wrong author for the last nine months?

Why isn't UDP with reliability (implemented at Application layer) a substitute of TCP?

Robots in a spaceship

A* pathfinding algorithm too slow

German idiomatic equivalents of 能骗就骗 (if you can trick, then trick)

Is it advisable to inform the CEO about his brother accessing his office?

Active wildlife outside the window- Good or Bad for Cat psychology?



The database data is not updated in the application


Ship an application with a databaseIs quitting an application frowned upon?How do I pass data between Activities in Android application?Android database recreates every time application is launchedAndroid SQL Database - rawQuery() Source not FoundWhy does my exception handler not trap Android SQLite insert error?Cursor for database on sdcard not closing or deactiveUse prepopulated SQLite database in android while using exisntent android APISqlite Join errorRoom Android - How to handle database version upgrade













-1















Please help. When changing the database version in the code, nothing comes - the data in the application remains from the old database.



Where is the problem?
I make changes to the database. I change the database version number, but nothing changes in the application.



class DatabaseHelper extends SQLiteOpenHelper 
private static String DB_PATH;
private static String DB_NAME = "bd.db";
private static final int SCHEMA = 28; //version
static final String TABLE = "categories_second";
private Context myContext;

DatabaseHelper(Context context)
super(context, DB_NAME, null, SCHEMA);
this.myContext = context;
DB_PATH = context.getFilesDir().getPath() + DB_NAME;


@Override
public void onCreate(SQLiteDatabase db)
db.execSQL("CREATE TABLE "+TABLE+"(_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,name TEXT NOT NULL,items TEXT,categories INTEGER DEFAULT NULL,pictures TEXT)");


@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
db.execSQL("DROP TABLE IF EXISTS " + TABLE);
onCreate(db);


void create_db()
InputStream myInput = null;
OutputStream myOutput = null;
try
File file = new File(DB_PATH);
if (!file.exists())
this.getReadableDatabase();

myInput = myContext.getAssets().open(DB_NAME);

String outFileName = DB_PATH;
myOutput = new FileOutputStream(outFileName);

byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0)
myOutput.write(buffer, 0, length);


myOutput.flush();
myOutput.close();
myInput.close();

catch (IOException ex)
Log.d("DatabaseHelper", ex.getMessage());



public SQLiteDatabase open() throws SQLException
return SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE);




Thank you in advance










share|improve this question



















  • 3





    It's not clear what you're expecting to happen, exactly, but I would point out that you never call create_db() anywhere.

    – Mike M.
    Mar 25 at 9:45
















-1















Please help. When changing the database version in the code, nothing comes - the data in the application remains from the old database.



Where is the problem?
I make changes to the database. I change the database version number, but nothing changes in the application.



class DatabaseHelper extends SQLiteOpenHelper 
private static String DB_PATH;
private static String DB_NAME = "bd.db";
private static final int SCHEMA = 28; //version
static final String TABLE = "categories_second";
private Context myContext;

DatabaseHelper(Context context)
super(context, DB_NAME, null, SCHEMA);
this.myContext = context;
DB_PATH = context.getFilesDir().getPath() + DB_NAME;


@Override
public void onCreate(SQLiteDatabase db)
db.execSQL("CREATE TABLE "+TABLE+"(_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,name TEXT NOT NULL,items TEXT,categories INTEGER DEFAULT NULL,pictures TEXT)");


@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
db.execSQL("DROP TABLE IF EXISTS " + TABLE);
onCreate(db);


void create_db()
InputStream myInput = null;
OutputStream myOutput = null;
try
File file = new File(DB_PATH);
if (!file.exists())
this.getReadableDatabase();

myInput = myContext.getAssets().open(DB_NAME);

String outFileName = DB_PATH;
myOutput = new FileOutputStream(outFileName);

byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0)
myOutput.write(buffer, 0, length);


myOutput.flush();
myOutput.close();
myInput.close();

catch (IOException ex)
Log.d("DatabaseHelper", ex.getMessage());



public SQLiteDatabase open() throws SQLException
return SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE);




Thank you in advance










share|improve this question



















  • 3





    It's not clear what you're expecting to happen, exactly, but I would point out that you never call create_db() anywhere.

    – Mike M.
    Mar 25 at 9:45














-1












-1








-1








Please help. When changing the database version in the code, nothing comes - the data in the application remains from the old database.



Where is the problem?
I make changes to the database. I change the database version number, but nothing changes in the application.



class DatabaseHelper extends SQLiteOpenHelper 
private static String DB_PATH;
private static String DB_NAME = "bd.db";
private static final int SCHEMA = 28; //version
static final String TABLE = "categories_second";
private Context myContext;

DatabaseHelper(Context context)
super(context, DB_NAME, null, SCHEMA);
this.myContext = context;
DB_PATH = context.getFilesDir().getPath() + DB_NAME;


@Override
public void onCreate(SQLiteDatabase db)
db.execSQL("CREATE TABLE "+TABLE+"(_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,name TEXT NOT NULL,items TEXT,categories INTEGER DEFAULT NULL,pictures TEXT)");


@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
db.execSQL("DROP TABLE IF EXISTS " + TABLE);
onCreate(db);


void create_db()
InputStream myInput = null;
OutputStream myOutput = null;
try
File file = new File(DB_PATH);
if (!file.exists())
this.getReadableDatabase();

myInput = myContext.getAssets().open(DB_NAME);

String outFileName = DB_PATH;
myOutput = new FileOutputStream(outFileName);

byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0)
myOutput.write(buffer, 0, length);


myOutput.flush();
myOutput.close();
myInput.close();

catch (IOException ex)
Log.d("DatabaseHelper", ex.getMessage());



public SQLiteDatabase open() throws SQLException
return SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE);




Thank you in advance










share|improve this question
















Please help. When changing the database version in the code, nothing comes - the data in the application remains from the old database.



Where is the problem?
I make changes to the database. I change the database version number, but nothing changes in the application.



class DatabaseHelper extends SQLiteOpenHelper 
private static String DB_PATH;
private static String DB_NAME = "bd.db";
private static final int SCHEMA = 28; //version
static final String TABLE = "categories_second";
private Context myContext;

DatabaseHelper(Context context)
super(context, DB_NAME, null, SCHEMA);
this.myContext = context;
DB_PATH = context.getFilesDir().getPath() + DB_NAME;


@Override
public void onCreate(SQLiteDatabase db)
db.execSQL("CREATE TABLE "+TABLE+"(_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,name TEXT NOT NULL,items TEXT,categories INTEGER DEFAULT NULL,pictures TEXT)");


@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
db.execSQL("DROP TABLE IF EXISTS " + TABLE);
onCreate(db);


void create_db()
InputStream myInput = null;
OutputStream myOutput = null;
try
File file = new File(DB_PATH);
if (!file.exists())
this.getReadableDatabase();

myInput = myContext.getAssets().open(DB_NAME);

String outFileName = DB_PATH;
myOutput = new FileOutputStream(outFileName);

byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0)
myOutput.write(buffer, 0, length);


myOutput.flush();
myOutput.close();
myInput.close();

catch (IOException ex)
Log.d("DatabaseHelper", ex.getMessage());



public SQLiteDatabase open() throws SQLException
return SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE);




Thank you in advance







java android sqlite






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 15:49









Sterling Archer

16.3k13 gold badges63 silver badges92 bronze badges




16.3k13 gold badges63 silver badges92 bronze badges










asked Mar 25 at 9:37









FerretBlackFerretBlack

11 bronze badge




11 bronze badge







  • 3





    It's not clear what you're expecting to happen, exactly, but I would point out that you never call create_db() anywhere.

    – Mike M.
    Mar 25 at 9:45













  • 3





    It's not clear what you're expecting to happen, exactly, but I would point out that you never call create_db() anywhere.

    – Mike M.
    Mar 25 at 9:45








3




3





It's not clear what you're expecting to happen, exactly, but I would point out that you never call create_db() anywhere.

– Mike M.
Mar 25 at 9:45






It's not clear what you're expecting to happen, exactly, but I would point out that you never call create_db() anywhere.

– Mike M.
Mar 25 at 9:45











1 Answer
1






active

oldest

votes


















0














How do you use DatabaseHelper?



I have simillar setup as you - without create_db



When I change the version in Helper, I also need to change version when I am calling the helper



dbHandler = new ButtonDBHandler(this, null, null, 2);





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334869%2fthe-database-data-is-not-updated-in-the-application%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    How do you use DatabaseHelper?



    I have simillar setup as you - without create_db



    When I change the version in Helper, I also need to change version when I am calling the helper



    dbHandler = new ButtonDBHandler(this, null, null, 2);





    share|improve this answer



























      0














      How do you use DatabaseHelper?



      I have simillar setup as you - without create_db



      When I change the version in Helper, I also need to change version when I am calling the helper



      dbHandler = new ButtonDBHandler(this, null, null, 2);





      share|improve this answer

























        0












        0








        0







        How do you use DatabaseHelper?



        I have simillar setup as you - without create_db



        When I change the version in Helper, I also need to change version when I am calling the helper



        dbHandler = new ButtonDBHandler(this, null, null, 2);





        share|improve this answer













        How do you use DatabaseHelper?



        I have simillar setup as you - without create_db



        When I change the version in Helper, I also need to change version when I am calling the helper



        dbHandler = new ButtonDBHandler(this, null, null, 2);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 10:11









        Quacking KahunaQuacking Kahuna

        235 bronze badges




        235 bronze badges
















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334869%2fthe-database-data-is-not-updated-in-the-application%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현