Android Question find older Version on Device

mw71

Well-Known Member
Licensed User
Longtime User
is there an Solution to find an older Version on Device??

The Problem is, i must cange the Package Name (Problem with oAuth2) from upper and lowercases to lowercase only. The Package name ifself was not changed!

The path to store the data I get with the following code:
B4X:
Dim paths() As Object = GetContext.RunMethod("getExternalFilesDirs", Array(Null))
With a Filemanager I see under /Android/Data/... only 1 corresponding directory. This is in lowercase (new Version of Package Name).

1. Problem:
The newer Version cant access to the SQLite Files and Folder until the older Version is uninstalled.

2. Problem:
If the older version is uninstalled, the stored data (in the ext. or internal memory) is lost. However, these are still required.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

mw71

Well-Known Member
Licensed User
Longtime User
Hi,


Which error do you get?

Write (new) SQLite DB in the Folder accessing by the other (older) Version:
(SQLiteCantOpenDatabaseException) android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 1294): Could not open database

open an existing database:
android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode
- i can view this File with SQLiteViewer
- it can be upload to GoogleDrive by the App


Use adb commandline tool.
for this i need the PC, i'm locking for a solution "with the App". I would like to give the user an info, so he can do this or the app can help him.
I should have written the question more precisely, sorry.
 
Upvote 0

mw71

Well-Known Member
Licensed User
Longtime User
Hi,

its "only" a new Version, not an new/other app. Changing the package name to lowercase is only necessary by modifying Google oAuth.
I will check if a new Package Name is a workaround.
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Just from a theoric point, I wonder if this would solve the problem without need of special actions taken by the customer

You need to build 2 apps (a nearly-empty transition one, and the "normal"one)
First app, "A": still with the not all lowercased package name. The "nearly empty" one. Will be needed only for the transition and will only perform only some actions
Second app "B": the fully functional app already with the lowercased package name, which has the normal functionality (plus a transition routine '*')

User downloads "A", as a regular upgrade of the existing app.
Once "A" is installed and launched, this new version will perform the following operations
Make (if it does not exist yet) a copy of the database to an external safe "backup" folder (it will have access to the working directory)
Once this is done and checked, app "A" downloads and installs the new all-lowercased package "B" (with the needed permissions)
Once done, "a" launches the new one "B" and finishes itself

The new app "B" (the fully working lowercase name app) does a first check at start.
If the old app (not lowercased) exists, uninstalls it (permissions)
Only if the database does not exist in the working directory and can be found in the "backup" directory, copy it, check everything is correct, and delete the backup
Then work normally

Possibly I am missing something, that's why I just wonder if it could be.o_O
 
Upvote 0

mw71

Well-Known Member
Licensed User
Longtime User
thanks for your anser JordiCP,

at the moment i test the follow
- set the new Version to Package name de.mycompany.myapp
- in the new Version Check for older Version with the follow Code:
B4X:
Sub CheckOlderVersion As Boolean
    Dim pm As PackageManager
    Dim packages As List
    Dim tmpStrg As String

    packages = pm.GetInstalledPackages
    For i = 0 To packages.Size - 1
        tmpStrg= packages.Get(i)
        If tmpStrg.ToLowerCase.Contains("de.myapp") Then
            Log(packages.Get(i) & ", " & _
               pm.GetVersionCode(packages.Get(i)) & ", " & _
                pm.GetVersionName(packages.Get(i)))
            If tmpStrg.ToLowerCase="de.myapp" And pm.GetVersionCode(packages.Get(i))<=20 Then
                Return True
            End If
        End If
    Next
    Return False
End Sub

if true (found older Version), i copy the old files to new folder, if the user has selected one.
Then the User can uninstall the older Version (if he wants).

Only to the settings (store in file.dirinternal) I can not access, this must unfortunately the user do again.
 
Upvote 0
Top