Display TextFile

by perumal316 » Thu, 21 Jan 2010 10:36:11 GMT


Sponsored Links
 Hi,

Suppose I have a text file in /data folder, is there any way I can
display the textfile to user through an app?

Thanks In Advance,
Perumal



Display TextFile

by TreKing » Fri, 22 Jan 2010 00:05:56 GMT


 



Sure. If you want to do this yourself, just read the contents of the file
and dump it to a TextView or something you can show in an Activity or a
Dialog.

If you want to use a separate app, create an Intent with a URI created from
the path to the file and call startActivity with that Intent. The user can
then choose which app to use to open the file, of the ones that are capable
of handling that file type.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 


Sponsored Links


Display TextFile

by perumal316 » Fri, 22 Jan 2010 10:10:40 GMT


 Yah I have tried using TextView but I am getting blank screen. Is it
correct to use the following code to access the file in /data
directory?

File file = new File(Environment.getDataDirectory(),"/data/
monitor.txt");

After which I did the reading by line and displaying using TextView
but getting blank screen

Regards,
Perumal






--



Display TextFile

by TreKing » Sat, 23 Jan 2010 03:45:13 GMT


 



Not really, use openFileInput() (I think that's the name, should be
something like that) to get an InputStream. Write out what you're getting
from the stream to the log to make sure the reading is successful before
trying to show it in the TextView.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 

--



Other Threads

1. Voice recording issues - ALSA, OMAP

Hey there,

I'm using omap based board (Devkit8000). I've managed to get the mic
working fine using alsa commands to capture audio. (alsa_aplay -C -t
wav -d 5 sample.wav) and it plays fine in the gui.

Few problems tho.

1. When i try playing a recorded sound (recorded via alsa_aplay
command) the sound's duration does not show up (the music player shows
the progress bar as complete). and logcat shows I/PVPlayer( 1932):
duration = -1


2. When recording through gui, through any application, the app fails
with mediaserver crashing and app giving numerous errors. the main
error i seem to get is this: Command PLAYER_SET_DATA_SOURCE completed
with an error or info PVMFErrNotSupported

Using android's soundrecorder app (sms>attach>record sound)

When i click record i get this (uv meter not moving):


I/ActivityManager(  906): Displayed activity
com.android.soundrecorder/.SoundRecorder: 411 ms (total 411 ms)
E/PV      ( 2022): PVLOG:TID(0x2aec8):Time=3:OsclLib::loadlibrary:
Error opening library (libomx_sharedlibrary_debug.so): Cannot load
library: load_library[1052]: Library 'libomx_sharedlibrary_debug.so'
not found
E/audio_input( 2022): unsupported parameter: x-pvmf/media-input-node/
cap-config-interface;valtype=key_specific_value
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=40:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=42:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=42:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=44:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=45:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=45:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=45:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=46:PVAuthorEngineNodeUtility::NodeCommandCompleted
E/PV      ( 2022):
PVLOG:TID(0x2aec8):Time=47:PVAuthorEngineNodeUtility::NodeCommandCompleted
W/AudioSystem(  906): AudioFlinger server died!
W/AudioSystem(  906): AudioPolicyService server died!
I/ServiceManager(  860): service 'media.audio_flinger' died
I/ServiceManager(  860): service 'media.player' died
I/ServiceManager(  860): service 'media.camera' died
I/ServiceManager(  860): service 'media.audio_policy' died
I/        ( 2053): ServiceManager: 0xad08
I/CameraService( 2053): CameraService started: pid=2053
D/AudioHardwareALSA( 2053): openOutputStream called for devices:
0x00000002
D/ALSAModule( 2053): open called for devices 00000002 in mode 0...
I/ALSAModule( 2053): Initialized ALSA PLAYBACK device AndroidPlayback
I/AudioFlinger( 2053): AudioFlinger's thread 0x21ac0 ready to run
D/ALSAModule( 2053): route called for devices 00000002 in mode 0...
E/AudioService(  906): Media server died.
E/AudioService(  906): Media server started.
W/AudioPolicyManagerALSA( 2053): setPhoneState() setting same state 0
D/dalvikvm( 1093): GC freed 1363 objects / 71880 bytes in 49ms
D/dalvikvm(  978): GC freed 431 objects / 24360 bytes in 76ms



Then i try to playback the sound, i get "Unable to access SD card"
dialog. and following:


E/PV      ( 2053): PVLOG:TID(0x2b128):Time=2:OsclLib::loadlibrary:
Error opening library (libomx_sharedlibrary_debug.so): Cannot load
library: load_library[1052]: Library 'libomx_sharedlibrary_debug.so'
not found
E/PV      ( 2053): PVLOG:TID(0x2b128):Time=11:OsclLib::loadlibrary:
Error opening library (libopencore_streamingreg_debug.so): Cannot load
library: load_library[1052]: Library
'libopencore_streamingreg_debug.so' not found
E/PV      ( 2053): PVLOG:TID(0x2b128):Time=14:OsclLib::loadlibrary:
Error opening library (libopencore_downloadreg_debug.so): Cannot load
library: load_library[1052]: Library
'libopencore_downloadreg_debug.so' not found
E/PV      ( 2053): PVLOG:TID(0x2b128):Time=17:OsclLib::loadlibrary:
Error opening library (libopencore_mp4localreg_debug.so): Cannot load
library: load_library[1052]: Library
'libopencore_mp4localreg_debug.so' not found
E/PV      ( 2053): PVLOG:TID(0x2b128):Time=23:OsclLib::loadlibrary:
Error opening library (libopencore_mp4localreg_debug.so): Cannot load
library: load_library[1052]: Library
'libopencore_mp4localreg_debug.so' not found
E/PV      ( 2053):
PVLOG:TID(0x2b128):Time=31:PVMFRecognizerRegistryImpl::CheckForDataAvailability
- RequestReadCapacityNotification Failed
W/MediaPlayer( 1921): info/warning (1, 26)
E/PlayerDriver( 2053): Command PLAYER_SET_DATA_SOURCE completed with
an error or info PVMFErrNotSupported
E/MediaPlayer( 1921): error (1, -4)
W/PlayerDriver( 2053): PVMFInfoErrorHandlingComplete
I/MediaPlayer( 1921): Info (1,26)


So what seems to be the issue? I have a feeling it relates back to the
driver as I can't figure out why there is no duration on the recorded
item... but im not sure if thats the main issue.

Can anyone shed some light?

-- 

2. Contact API problem with save datas Options

I'm facing a basic problem but i didn't find any tutorial in order to
help me...

I'm writing an application with sort of backup contact options. I want
that my applications works for android phones since 1.5 to 2.2

So i write a two implementation of ContactApi, one for 1.5, 1.6 and an
other for new api version.

Here is the list of problem I'm facing with.

With new api, nothing. All works fine, backing up contacts works well.

But with older api I'm not able to backing up some datas :

Email Datas (able to read, but not able to save)
IM datas (able to read, but not able to save)
Notes (able to read the first note, if many notes, I lost datas, same
things for backup)
Here is the code I'm using :

=======EMAIL=======

 private ArrayList<Email> getEmailAddresses(String id) {
            ArrayList<Email> emails = new ArrayList<Email>();
            Cursor emailCur =
this.contentResolver.query(Contacts.ContactMethods.CONTENT_EMAIL_URI,
null, Contacts.ContactMethods.PERSON_ID + " = ?", new String[] { id },
null);
            Email email = null;
            while (emailCur.moveToNext()) {
                    // This would allow you get several email
addresses
                    email = new Email();
 
email.setData(emailCur.getString(emailCur.getColumnIndex(Contacts.ContactMe
thods.DATA)));
 
email.setType(emailCur.getInt(emailCur.getColumnIndex(Contacts.ContactMetho
ds.TYPE)));
 
email.setLabel(emailCur.getString(emailCur.getColumnIndex(Contacts.PeopleCo
lumns.NAME)));
                    emails.add(email);
            }
            emailCur.close();
            return emails;
    }
private void saveEmailAddresses(ContentUris contactUri, List<Email>
emailList, String id) {
            if (emailList != null && emailList.size() > 0) {
                    ContentValues values = null;
                    ContentValues[] valueArray = new
ContentValues[emailList.size()];
                    int i = 0;
                    for (Email email : emailList) {
                            values = new ContentValues();
 
values.put(Contacts.ContactMethods.PERSON_ID, id); //
                            values.put(Contacts.ContactMethods.KIND,
Contacts.KIND_EMAIL); //
                            values.put(Contacts.ContactMethods.DATA,
email.getData()); //
                            values.put(Contacts.ContactMethods.TYPE,
email.getType()); //
                            values.put(Contacts.PeopleColumns.NAME,
email.getLabel()); //
                            valueArray[i] = values;
                            i++;
                    }
 
contentResolver.bulkInsert(Contacts.ContactMethods.CONTENT_EMAIL_URI,
valueArray);
            }
    }

======== IM adress=============


 private ArrayList<IM> getIM(Cursor cur, String id) {
                ArrayList<IM> imList = new ArrayList<IM>();
                String where = Contacts.ContactMethods.PERSON_ID + "
= ? AND " +     Contacts.ContactMethods.KIND + " = ?";
                String[] whereParameters = new String[] { id,
String.valueOf(Contacts.KIND_IM) };
                Cursor imCur =
this.contentResolver.query(Contacts.ContactMethods.CONTENT_URI, null,
where, whereParameters, null);
                IM im = null;
                while (imCur.moveToNext()) {
                        try {
                                String imName =
imCur.getString(imCur.getColumnIndex(Contacts.ContactMethodsColumns.DATA));
                                        im = new IM();
                                        im.setName(imName);
im.setType(imCur.getInt(imCur.getColumnIndex(Contacts.ContactMethodsColumns 
.TYPE)));
im.setProtocol(cur.getString(imCur.getColumnIndex(Contacts.ContactMethods.A
UX_DATA)));
                                        imList.add(im);
                        } catch (Exception e) {
                                Log.e(where, "Error im : ", e);
                        }
                }
                imCur.close();
                return imList;
        }
        private void saveIM(List<IM> imList, String id) {
                if (imList != null && imList.size() > 0) {
                        ContentValues values = null;
                        ContentValues[] valueArray = new
ContentValues[imList.size()];
                        int i = 0;
                        for (IM im : imList) {
                                values = new ContentValues();
 
values.put(Contacts.ContactMethods.PERSON_ID, id); //
 
values.put(Contacts.ContactMethods.KIND, Contacts.KIND_IM); //
 
values.put(Contacts.ContactMethodsColumns.DATA, im.getName()); //
 
values.put(Contacts.ContactMethods.AUX_DATA,
ContactMethods.encodeCustomImProtocol(im.getProtocol())); //
 
values.put(Contacts.ContactMethodsColumns.TYPE, im.getType()); //
                                valueArray[i] = values;
                                i++;
                        }
 
contentResolver.bulkInsert(Contacts.ContactMethods.CONTENT_URI,
valueArray);
                }
        }
==========Notes =======

I have no idea how to get all notes ?

Can someone help me with this ?

-- 

3. lower EditText isn't panned to when opening the Virtual Keyboard

4. [WTA] Desire screen tearing

5. [WTA]wipe batterystats

6. Apa selanjutnya setelah update ke froyo

7. sdcard, external_sd