Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you need is a unique ID for each file in your database, and to link all of your tags with that ID <em>instead</em> of the filename (it can generated however you like, an integer or a hash or random numbers will be all fine, all that matters is that no other file has the same ID otherwise the tags will be shown for both files).</p> <p>In your database you can keep one table which links the names of the files to the ID (or, more flexibly, link the IDs with the paths to the files and extract the names from that when you need them). When you add a tag, link it to that ID like you would the filename. It costs you a trivial ID database lookup when you load a file's tags, but allows you to rename your files in one place (rather than having to walk through the database looking for the filename).</p> <p>To catch people renaming your files, you can create a <a href="http://developer.android.com/reference/android/os/FileObserver.html" rel="nofollow">FileObserver</a> to watch for <a href="http://developer.android.com/reference/android/os/FileObserver.html#MOVE_SELF" rel="nofollow">MOVE_SELF</a> events (which would be renames - a rename is the same as a move). You can override the <a href="http://developer.android.com/reference/android/os/FileObserver.html#onEvent" rel="nofollow">FileObserver.onEvent()</a> method, where you can update your database with the new name of the file. You'll want to do this in a separate thread, to avoid locking up the UI. It also won't persist after your activity, so you would want to either have a Service to hold the FileObserver and update your database, or just have some kind of scan happening when your Activity is launched.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload