Moving a file ?

Put your problem here if it does not fit any of the other categories.

Moving a file ?

Postby Jompe71 » Tue Oct 27, 2009 7:41 pm

How do you guys move (rename) a file?
I wan't to rename a file named "<file>.loc.tmp" to "<file>.loc" within the same directory.
The .loc file already exists b.t.w. but I don't think thats the issue coz the same code works on Windows but nither in the EMU nor on a real device.

Do I have to say it's urgent? :lol:

Tried both FileUtils.moveFile() and File.renameTo() ...same issue.

// Jompe71
There is no school like old school gaming.
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Top

Postby padde » Tue Oct 27, 2009 8:05 pm

If the file is on the SDCard you need the right permission..
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  3.  
  4.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby Jompe71 » Tue Oct 27, 2009 8:17 pm

No it's among the app data files, i.e. /data/data/<package>/<some_path>/ :?
There is no school like old school gaming.
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Postby padde » Tue Oct 27, 2009 8:55 pm

I think this just works if the app in that folder changes the file.. you cant change anything in a folder of an foreign app. Except both apps are signed with the same signature.. i guess.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby Jompe71 » Wed Oct 28, 2009 7:33 am

I think the issue here (after doing som reading about it) is that in order to delete a file one must use this method:
http://developer.android.com/reference/ ... ang.String)

My problem is that all file manipulation in my game engine is done from within a separate jar which I'd like to keep clean from Android dependencies.
That code uses FileUtils and regular Java API File methods to to stuff. Unfortunatly it seams that both API's in the case of a move request relies on copy + delete. Suppose thats how the native OS handles it anyway...
So the delete step naturally fails due to some Android restrictions causing Exception from FileUtils and a false response from code Java.

I'm gonna open up the game engine a bit to expose the files needed to "move" up to the Android abstraction level and this would probably fix it!
There is no school like old school gaming.
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 38 guests