Accessing another DB

by Skeniver » Mon, 12 Oct 2009 22:30:39 GMT


Sponsored Links
 Hey Skyhigh

I am faced with the same issue at the moment.

With the code you provided, does a user have to have both versions of
the app installed? Or did you just run that once to access the
database and then copy the data across to a new database? Or have I
missed the point completely?

Any help would be much appreciated

Thanks in advance,
Neil
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Still crash bugs in the Notepad tutorial, even in the final version

I asked on the android-developers list about this (before I knew of
the android-beginners list), and got no response. I really frown on
example and tutorial code with bugs. If you're trying to show "this is
how you do it", I think you should actually show the right way to do
it. This led to a crash in an app I'm developing when I assumed the
code was, y'know, correct.

Anyway, I'm contributing a solution here so others can hopefully not
be led too far astray. At least it forced me to get more familiar with
the de{*filter*}!

The problem is in "NoteEdit.java". Even in the final version of the
app, if this activity gets relaunched - e.g. by an orientation change
- it'll crash. This is because the logic involved in saving and
restoring state is faulty. Changes need to be made in onCreate() and
onSaveInstanceState().

 First, look at onSaveInstanceState(). If you've got an empty note
(say, the activity was launched with "Add Note"), then mRowId is null,
and trying to do an outState.putLong() will give you a fresh, exciting
NullPointerException. But if we don't save anything... when we try to
restore the value in onCreate(), we'll get the value 0L, which can be
a valid row ID! So instead, I do the following:

    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        // It's a no-no to try to save a null! So instead we save an
invalid row id...
        if (mRowId != null) {
                outState.putLong(NotesDbAdapter.KEY_ROWID, mRowId);
        } else {
                outState.putLong(NotesDbAdapter.KEY_ROWID, -1L);
        }
    }

 Note: I'm not 100% sure that "-1" is an invalid row ID - SQLite
apparently *can* support negative row IDs - but so far in my limited
testing it seems to be the case that Android won't generate such IDs
spontaneously. You have go out of your way to make them. If this is
not the case, please let me know!

 Now, back up in onCreate(), we modify our initialization as follows.
(I've gotten rid of the '?:' construct because it confuses the Eclipse
de{*filter*}, which bounces around to various unrelated lines if you try
to step through it.)

        // First, see if we have saved state we should use
        if (savedInstanceState != null) {
                mRowId = savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID);
                // Did we save an invalid row id?
                if (mRowId == -1L) {
                        // Make sure we don't try to use the invalid row!
                        mRowId = null;
                }
        } else {
                mRowId = null;
        }

        if (mRowId == null) {
                // Must not have been any saved state. Okay, were we launched 
with
an entry to edit?
                Bundle extras = getIntent().getExtras();
                if (extras != null) {
                        mRowId = extras.getLong(NotesDbAdapter.KEY_ROWID);
                }
        }

 This has been working for me in my tests. If anyone spots problems,
please let me know. Is there any way to get Google's attention on
this, maybe have them update the tutorial? Or at least have them add a
warning that serious bugs remain, even in their final version?

-- 

2. Nexus vs Incredible

Kesan paling gampang:

1. incredible lebih ringan, mungkin karena bodynya lebih banyak plastik
2. Trackball vs trackpad, ini lebih ke arah preferensi. Gue gak pake
dua duanya jadi gak terlalu mikirin
3. Kualitas warna relatif sama
4. Kamera 8MP di incredible sama 5MP di nexus gak terlalu banyak beda
dari segi kualitas. Tapi tentunya 8MP akan lebih bermanfaat jika di
print compared dilihat di layar komputer maupun hp
5. Incredible tidak punya dedicated camera button (sucks!)
6. Yang paling nyebelin: Incredible belum bisa di root :( padahal gue
mau install wireless tether buat tethering dari iPad

Pemakaian:
1. Market tidak punya tab my download, adanya Verizon recommended :(
Jadi untuk aplikasi aplikasi yang kita beli harus search manual baru
redownload, gak bisa langsung select.
2. Sewaktu pertama kali nyala diprogram over the air, jadi gak tahu
deh kalau dibawa ke indo gimana programmingnya. Setiap factory reset
programming over the air ini harus dilakukan lagi.
3. Battery sama aja dengan Nexus, dalam penggunaan gue gak bakal
sampai lebih dari 12 jam
4. Yang pasti loving Verizon connectivity compared to T-Mobile, hueheheheh
5. Body belakang Incredible yang agak berundak undak agak menyusahkan
untuk menggunakan invisible body protector, lalu kayanya kalau pake
silicon yang gak ikut textur body jadi aneh deh
6. Konektor menggunakan micro-usb seperti Nexus


Itu dulu untuk {*filter*}tara, siapa tahu jadi bikin tambah penasaran huahahahahaha

-- 
"Indonesian Android Community [id-android]" 

Join:  http://www.***.com/ 
Moderator: id.andr...@gmail.com
ID Android Developer:  http://www.***.com/ 
ID Android Surabaya:  http://www.***.com/ 
ID Android on FB:  http://www.***.com/ 

3. volume key pressed to ignore call

4. Kalo moto clic bagus ga sh?romnya susah ga ulik2 nya?

5. Sales down in may?

6. AudioPara patch for magic 32a

7. Strange Error: WIN DEATH: Window{44bba600 SurfaceView paused=false}